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)),
]
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__':