|
|
|
|
@ -3,6 +3,8 @@ import pathlib
@@ -3,6 +3,8 @@ import pathlib
|
|
|
|
|
import tempfile |
|
|
|
|
import subprocess |
|
|
|
|
|
|
|
|
|
from .travels import _search_travel_notes |
|
|
|
|
|
|
|
|
|
OSIDIAN_SEPARATOR ="---\n" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -54,7 +56,7 @@ def fill_fields(body, fields):
@@ -54,7 +56,7 @@ def fill_fields(body, fields):
|
|
|
|
|
return body |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def convert_file(markdown) -> str: |
|
|
|
|
def convert_file(markdown, *, move_original=True) -> str: |
|
|
|
|
path = pathlib.Path(markdown) |
|
|
|
|
content = path.read_text() |
|
|
|
|
header, body = split_header(content) |
|
|
|
|
@ -74,16 +76,18 @@ def convert_file(markdown) -> str:
@@ -74,16 +76,18 @@ def convert_file(markdown) -> str:
|
|
|
|
|
cmd = ["typst", "compile", f"{typist}", f"{output}"] |
|
|
|
|
subprocess.run(cmd) |
|
|
|
|
|
|
|
|
|
moved = get_destination() / f"Checkliste {path.name}" |
|
|
|
|
subprocess.run(["mv", f"{path}", moved]) |
|
|
|
|
if move_original: |
|
|
|
|
moved = get_destination() / f"Checkliste {path.name}" |
|
|
|
|
subprocess.run(["mv", f"{path}", moved]) |
|
|
|
|
|
|
|
|
|
return f"{output}" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@click.command() |
|
|
|
|
@click.argument( |
|
|
|
|
"markdowns", nargs=-1, type=click.Path(exists=True, file_okay=True, dir_okay=False) |
|
|
|
|
) |
|
|
|
|
def convert(markdowns): |
|
|
|
|
for name in markdowns: |
|
|
|
|
path = convert_file(name) |
|
|
|
|
print(path) |
|
|
|
|
@click.argument("travel_numbers", nargs=-1) |
|
|
|
|
@click.option("--debug", is_flag=True) |
|
|
|
|
def convert(travel_numbers, debug): |
|
|
|
|
for number in travel_numbers: |
|
|
|
|
mkd_path = _search_travel_notes(number) |
|
|
|
|
out_path = convert_file(mkd_path, move_original=(not debug)) |
|
|
|
|
print(out_path) |