Don't use Pandoc, wiki can do Markdown now.

This commit is contained in:
raute 2024-05-07 23:39:36 +02:00
parent f918c09a35
commit 776e564a1a
1 changed files with 7 additions and 13 deletions

View File

@ -14,9 +14,8 @@ months = ["",
clipboard = subprocess.check_output(["xclip", "-out", "-selection", "clipboard"]).decode()
m = re.match(
r"# ([0-9][0-9]+)\. Plenum .+ ([0-9]{1,2})\. (" + "|".join(months[1:]) + ") (20[0-9]{2})",
clipboard)
m = re.match(r"# ([0-9][0-9]+)\. Plenum .+ ([0-9]{1,2})\. (" + "|".join(months[1:]) + ") (20[0-9]{2})",
clipboard)
if not m:
print("Error: Überschrift nicht erkannt.", file=sys.stderr)
sys.exit(1)
@ -44,19 +43,14 @@ if month_later == 13:
month_name = month_name.lower()
earlier = "verein:plenum:{}_{}_{}".format(str(num - 1).rjust(3, "0"),
months[month_earlier].lower(),
months[month_earlier].lower().replace("ä", "ae"),
year_earlier)
later = "verein:plenum:{}_{}_{}".format(str(num + 1).rjust(3, "0"),
months[month_later].lower(),
months[month_later].lower().replace("ä", "ae"),
year_later)
links = "[⇐ vorheriges Plenum]({}) | [nächstes Plenum ⇒]({})".format(earlier,
later)
links = "[⇐ vorheriges Plenum]({}) | [nächstes Plenum ⇒]({})".format(earlier, later)
markdown = "{}\n\n{}".format(links, clipboard)
pandoc_output = subprocess.check_output(["pandoc", "-f", "markdown", "-t", "dokuwiki"],
input=markdown.encode()).decode()
replaced = pandoc_output.replace("[x]",
"<fs x-large>☑</fs>").replace("[ ]",
"<fs x-large>☐</fs>")
output = f"<!DOCTYPE markdown>\n\n{markdown}"
replaced = output.replace("[x]", "<fs x-large>☑</fs>").replace("[ ]", "<fs x-large>☐</fs>")
subprocess.run(["xclip", "-in", "-selection", "clipboard"], input=replaced.encode())
print("Dokuwiki-Code kopiert.")