From 93ee73e1dc0405ddf71417d907656c2a8726f133 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 29 Mar 2019 10:04:22 -0700 Subject: LaTeX writer: Avoid inadvertently creating ?` or !` ligatures. These are upside down ? and !, resp. Closes #5407. --- src/Text/Pandoc/Writers/LaTeX.hs | 8 ++++++++ test/command/5407.md | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/command/5407.md diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index 0ef04db3f..d0c08815c 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -340,6 +340,14 @@ stringToLaTeX context zs = do -> cs <> xs _ -> cs <> "{}" <> xs in case x of + '?' | ligatures -> -- avoid ?` ligature + case xs of + '`':_ -> emits "?{}" + _ -> emitc x + '!' | ligatures -> -- avoid !` ligature + case xs of + '`':_ -> emits "!{}" + _ -> emitc x '{' -> emits "\\{" '}' -> emits "\\}" '`' | ctx == CodeString -> emitcseq "\\textasciigrave" diff --git a/test/command/5407.md b/test/command/5407.md new file mode 100644 index 000000000..ac9bed29d --- /dev/null +++ b/test/command/5407.md @@ -0,0 +1,14 @@ +``` +% pandoc -t latex --wrap=preserve +hi there?“ +hi there!“ +hi there?‘ +hi there!‘ +hi there! +^D +hi there?{}`` +hi there!{}`` +hi there?{}` +hi there!{}` +hi there! +``` -- cgit v1.2.3