From 9fdc99b838ddd4ad9c68100671ccae3286e2c723 Mon Sep 17 00:00:00 2001 From: Marcel Bollmann Date: Sun, 2 Jul 2023 15:45:00 +0200 Subject: [PATCH 1/3] Fix bug in formatting tex-math as text --- bin/anthology/formatter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/anthology/formatter.py b/bin/anthology/formatter.py index ad78724690..9220482376 100644 --- a/bin/anthology/formatter.py +++ b/bin/anthology/formatter.py @@ -174,6 +174,7 @@ def as_text(self, element): element = deepcopy(element) for sub in element.iterfind(".//tex-math"): sub.text = self.texmath.to_unicode(sub) + sub.tail = None # tail is contained within return value of texmath.to_unicode() retval = etree.tostring(element, encoding="unicode", method="text") return remove_extra_whitespace(retval) From 29d320a1da7faa8abfb927e88a90987bd69babd8 Mon Sep 17 00:00:00 2001 From: Marcel Bollmann Date: Sun, 2 Jul 2023 15:45:58 +0200 Subject: [PATCH 2/3] Fix bug in handling malformed \frac command --- bin/anthology/texmath.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/anthology/texmath.py b/bin/anthology/texmath.py index dedb347c9c..82eff7bc0e 100644 --- a/bin/anthology/texmath.py +++ b/bin/anthology/texmath.py @@ -158,7 +158,7 @@ def _parse_command(self, code, trg): def _parse_fraction(self, args, trg): if len(args) != 2: log.warn(f"Couldn't parse \\frac: got {len(args)} arguments, expected 2") - self._append_unparsed({'name': 'frac', 'args': args}, trg) + self._append_unparsed(TexCmd("frac", args=args), trg) else: # Represent numerator of fraction as superscript sx = etree.Element("sup") From af7bd805767be1bd810395b4e9d7fd6d2e8018c3 Mon Sep 17 00:00:00 2001 From: Marcel Bollmann Date: Sun, 2 Jul 2023 15:49:41 +0200 Subject: [PATCH 3/3] black --- bin/anthology/formatter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/anthology/formatter.py b/bin/anthology/formatter.py index 9220482376..f323920908 100644 --- a/bin/anthology/formatter.py +++ b/bin/anthology/formatter.py @@ -174,7 +174,9 @@ def as_text(self, element): element = deepcopy(element) for sub in element.iterfind(".//tex-math"): sub.text = self.texmath.to_unicode(sub) - sub.tail = None # tail is contained within return value of texmath.to_unicode() + sub.tail = ( + None # tail is contained within return value of texmath.to_unicode() + ) retval = etree.tostring(element, encoding="unicode", method="text") return remove_extra_whitespace(retval)