From 87fb552dd37301bc0834afc09aa99cadd6310b98 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 29 Dec 2023 11:49:08 -0800 Subject: [PATCH 1/1] Apply bare-\emph fix to \st too --- texfilter.py | 4 ++-- texfilter_test.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/texfilter.py b/texfilter.py index 8103c19..de3674b 100644 --- a/texfilter.py +++ b/texfilter.py @@ -11,8 +11,8 @@ from typing import Callable, List, Tuple TexFilters: List[Tuple[str, Callable[[bytes], bytes]]] = [ # Work around `Extra }, or forgotten \endgroup.` - ("FixBareEmph", lambda x: re.sub( - b'(^|\n)(\\\\emph{)', b'\\1\\\\hspace{0pt}\\2', x)), + ("FixBareNesting", lambda x: re.sub( + b'(^|\n)(\\\\(emph|st){)', b'\\1\\\\hspace{0pt}\\2', x)), ] diff --git a/texfilter_test.py b/texfilter_test.py index 8b603a3..66144e8 100644 --- a/texfilter_test.py +++ b/texfilter_test.py @@ -13,11 +13,14 @@ class TestTexFilters(unittest.TestCase): def testStripNBSP(self) -> None: self.assertEqual( - ApplyTexFilters("FixBareEmph", b'\\emph{Yes?}'), + ApplyTexFilters("FixBareNesting", b'\\emph{Yes?}'), b'\\hspace{0pt}\\emph{Yes?}') self.assertEqual( - ApplyTexFilters("FixBareEmph", b'Reassuring.\n\n\\emph{Yes?}'), + ApplyTexFilters("FixBareNesting", b'Reassuring.\n\n\\emph{Yes?}'), b'Reassuring.\n\n\\hspace{0pt}\\emph{Yes?}') + self.assertEqual( + ApplyTexFilters("FixBareNesting", b'\\st{Nope}'), + b'\\hspace{0pt}\\st{Nope}') if __name__ == '__main__': -- 2.44.1