aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-02 12:31:54 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-02 12:31:54 +0200
commit4655e38357017574ba730dbdde7fae73e9b153dd (patch)
treeff92dcdcaed9d8d163dfa6cde953b1c6d303b869
parent05ff47874d7e40636061cdd99b9868de7bbb6941 (diff)
fix bulk-cleanup.py
-rw-r--r--anki-card-template/.gitignore1
-rwxr-xr-xanki-card-template/bulk-cleanup.py16
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)