From 63a1710cd4956ee17f8196c64c981c8ecf60f367 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 8 Sep 2026 22:49:34 +0000 Subject: [PATCH] LaTeX reader: keep ASCII quotes when ligatures are disabled. Commit 47610fe3d (#10781) disabled the `--`, `---`, and `"` ligatures inside `\texttt`, but single `` ` `` and `'` characters were still converted to curly quotes, so `\texttt{it's}` produced code containing a Unicode right single quotation mark. Gate those conversions on the ligatures flag too, so quote characters inside `\texttt` stay as typed. Update test/command/3958.md accordingly. Co-Authored-By: Claude --- src/Text/Pandoc/Readers/LaTeX.hs | 9 ++++++--- test/Tests/Readers/LaTeX.hs | 9 +++++++++ test/command/3958.md | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index c088635aa..af543c764 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -823,13 +823,16 @@ inline = do -> eatOneToken *> option (str "-") (symbol '-' *> option (str "–") (str "—" <$ symbol '-')) - "'" -> eatOneToken *> - option (str "’") (str "”" <$ (guard ligatures *> symbol '\'')) + "'" | ligatures + -> eatOneToken *> + option (str "’") (str "”" <$ symbol '\'') + | otherwise + -> symbolAsString "~" -> str "\160" <$ eatOneToken "`" | ligatures -> doubleQuote <|> singleQuote <|> (str "‘" <$ symbol '`') | otherwise - -> str "‘" <$ symbol '`' + -> symbolAsString "\"" | ligatures -> doubleQuote <|> singleQuote <|> symbolAsString "“" -> doubleQuote <|> symbolAsString diff --git a/test/Tests/Readers/LaTeX.hs b/test/Tests/Readers/LaTeX.hs index 1827c609e..c57673309 100644 --- a/test/Tests/Readers/LaTeX.hs +++ b/test/Tests/Readers/LaTeX.hs @@ -262,6 +262,15 @@ tests = [ testGroup "basic" "\\newif\\foobar\\foobar hi\\fi" =?> para (str "hi") ] + , testGroup "ligatures" + [ "quote ligatures in normal text" =: + "it's ``x'' `y'" =?> + para ("it\8217s " <> doubleQuoted "x" <> " " <> singleQuoted "y") + , "apostrophe in texttt stays ASCII" =: + "\\texttt{it's}" =?> para (code "it's") + , "backtick in texttt stays ASCII" =: + "\\texttt{`x'}" =?> para (code "`x'") + ] , testGroup "urls" [ "url with escaped %" =: "\\url{http://example.com/a\\%b}" =?> diff --git a/test/command/3958.md b/test/command/3958.md index 67f550f0b..91080feab 100644 --- a/test/command/3958.md +++ b/test/command/3958.md @@ -9,12 +9,12 @@ % pandoc -f latex -t native \texttt{``hi''} ^D -[ Para [ Code ( "" , [] , [] ) "\8216\8216hi\8217\8217" ] ] +[ Para [ Code ( "" , [] , [] ) "``hi''" ] ] ``` ``` % pandoc -f latex -t native \texttt{`hi'} ^D -[ Para [ Code ( "" , [] , [] ) "\8216hi\8217" ] ] +[ Para [ Code ( "" , [] , [] ) "`hi'" ] ] ```