]> git.scottworley.com Git - paperdoorknob/commitdiff
Apply bare-\emph fix to \st too
authorScott Worley <scottworley@scottworley.com>
Fri, 29 Dec 2023 19:49:08 +0000 (11:49 -0800)
committerScott Worley <scottworley@scottworley.com>
Fri, 29 Dec 2023 19:49:08 +0000 (11:49 -0800)
texfilter.py
texfilter_test.py

index 8103c19df2cef6475e1a9e9fb29ac637196a07ac..de3674b82f04a414cec9e7323ca41b8d8f0d1938 100644 (file)
@@ -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)),
 ]
 
 
index 8b603a3282c3ebdaf03be4d669ccc3ba0d2a1ee6..66144e821656398ec53d1a4c2e5936c36ca8f578 100644 (file)
@@ -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__':