diff options
-rw-r--r-- | anki-card-template/.gitignore | 1 | ||||
-rwxr-xr-x | 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) |