From: Scott Worley Date: Fri, 29 Dec 2023 19:49:08 +0000 (-0800) Subject: Apply bare-\emph fix to \st too X-Git-Url: http://git.scottworley.com/paperdoorknob/commitdiff_plain/87fb552dd37301bc0834afc09aa99cadd6310b98?ds=sidebyside Apply bare-\emph fix to \st too --- 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__':