From 30b145cc4660ae5d86bd0de88e373d3107ba54d5 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 26 Jan 2024 00:37:41 -0800 Subject: [PATCH 1/1] =?utf8?q?Handle=20Unicode=20characters=20=E2=89=88=20?= =?utf8?q?and=20=E2=97=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. :( --- paperdoorknob.py | 1 + texfilter.py | 2 ++ 2 files changed, 3 insertions(+) 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)), ] -- 2.44.1