From 4655e38357017574ba730dbdde7fae73e9b153dd Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 2 Oct 2024 12:31:54 +0200 Subject: fix bulk-cleanup.py --- anki-card-template/.gitignore | 1 + anki-card-template/bulk-cleanup.py | 16 +++------------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/anki-card-template/.gitignore b/anki-card-template/.gitignore index e49c5f5..6c9f136 100644 --- a/anki-card-template/.gitignore +++ b/anki-card-template/.gitignore @@ -1 +1,2 @@ *-template.html +__pycache__ diff --git a/anki-card-template/bulk-cleanup.py b/anki-card-template/bulk-cleanup.py index 8bf3e5c..c712c51 100755 --- a/anki-card-template/bulk-cleanup.py +++ b/anki-card-template/bulk-cleanup.py @@ -21,21 +21,11 @@ sys.stdout = trash_out import aqt sys.stdout = real_stdout -def escape(plain): - plain = plain.replace("*", "\\*") - plain = plain.replace("(", "\\(") - plain = plain.replace(")", "\\)") - plain = plain.replace("[", "\\[") - plain = plain.replace("]", "\\]") - plain = plain.replace("{", "\\{") - plain = plain.replace("}", "\\}") - return plain - def recurseplainify(soup): output = "" for el in soup.children: - if el.string: - output += escape(el.string) + if el.name == None: + output += el.string continue if el.name == 'b': @@ -43,7 +33,7 @@ def recurseplainify(soup): continue if el.name == 'ruby': - output += f'[{escape(el.text)}]({escape(el.rt.text)})' + output += f'[{el.text}]({el.rt.text})' continue output += recurseplainify(el) -- cgit v1.2.3