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