From bfae31ae23e85349d9c8decafbdcec41c24964a7 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Tue, 1 Mar 2022 08:28:43 +0100 Subject: [PATCH] bib2html.py: Better math replacing Kill dollar signs and \mathcal in the output text. --- bib2html.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bib2html.py b/bib2html.py index 3ad3a93..64286f2 100755 --- a/bib2html.py +++ b/bib2html.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Creates a webpage with all entries of a .bib file""" -__version__ = "1.0" +__version__ = "1.1" __author__ = "Stefan Huber" __email__ = "shuber@sthu.org" @@ -31,11 +31,13 @@ __license__ = "MIT" # OTHER DEALINGS IN THE SOFTWARE. -import os, sys, getopt +import os, sys, getopt, re def format_latex(text): - return text.replace('{', '').replace('}', '').replace('\\', '') + # Get rid of matching dollar signs + text = re.sub(r'\$([^\$]*)\$', r'\1', text) + return text.replace('\mathcal', '').replace('{', '').replace('}', '').replace('\\', '') def format_field_span(type, value): return "" + format_latex(value) + "" -- 2.30.2