From: Scott Worley Date: Fri, 26 Jan 2024 08:37:41 +0000 (-0800) Subject: Handle Unicode characters ≈ and ◁ X-Git-Url: http://git.scottworley.com/paperdoorknob/commitdiff_plain Handle Unicode characters ≈ and ◁ This is a temporary expediency. These characters sometimes appear in a math expression and sometimes outside of a math expression, so when we start correctly rendering math expressions, we can't just blindly jump into math mode like this. :( --- diff --git a/paperdoorknob.py b/paperdoorknob.py index ed7813b..5ad341f 100644 --- a/paperdoorknob.py +++ b/paperdoorknob.py @@ -11,6 +11,7 @@ from spec import Spec def process(spec: Spec) -> None: spec.texout.write(br'''\documentclass{article} +\usepackage{amssymb} \usepackage{booktabs} \usepackage{graphicx} \usepackage{longtable} diff --git a/texfilter.py b/texfilter.py index de3674b..e215b18 100644 --- a/texfilter.py +++ b/texfilter.py @@ -13,6 +13,8 @@ TexFilters: List[Tuple[str, Callable[[bytes], bytes]]] = [ # Work around `Extra }, or forgotten \endgroup.` ("FixBareNesting", lambda x: re.sub( b'(^|\n)(\\\\(emph|st){)', b'\\1\\\\hspace{0pt}\\2', x)), + ("UnicodeApprox", lambda x: re.sub('≈'.encode('utf-8'), b'$\\approx$', x)), + ("UnicodeTriangle", lambda x: re.sub('◁'.encode('utf-8'), b'$\\lhd$', x)), ]