bib2html.py: Add umlaut replacement
authorStefan Huber <shuber@sthu.org>
Tue, 1 Aug 2023 07:31:42 +0000 (09:31 +0200)
committerStefan Huber <shuber@sthu.org>
Tue, 1 Aug 2023 07:31:42 +0000 (09:31 +0200)
bib2html.py

index dee284ec3a1a51239ab019801bed5e9bd772ab90..5d5b4db16f6e75bbd796858d792714130052a614 100755 (executable)
@@ -37,7 +37,25 @@ import os, sys, getopt, re
 def format_latex(text):
     # Get rid of matching dollar signs
     text = re.sub(r'\$([^\$]*)\$', r'\1', text)
-    return text.replace('\mathcal', '').replace('{', '').replace('}', '').replace('\\', '').replace('~', ' ').replace('--', '–')
+
+    # Replace text
+    subst = {
+        '\\"a': 'ä',
+        '\\"o': 'ö',
+        '\\"u': 'u',
+        '\mathcal': '',
+        '{': '',
+        '}': '',
+        '\\': '',
+        '~': ' ',
+        '---': '–',
+        '--': '–',
+    }
+
+    for a, b in subst.items():
+        text = text.replace(a, b)
+
+    return text
 
 def format_field_span(type, value):
     return "<span class=bibentry_" + type + ">" + format_latex(value) + "</span>"