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 <noreply@anthropic.com>
This commit is contained in:
John MacFarlane
2026-09-08 16:10:11 -07:00
co-authored by Claude
parent ce060e98e6
commit 63a1710cd4
3 changed files with 17 additions and 5 deletions
+6 -3
View File
@@ -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
+9
View File
@@ -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}" =?>
+2 -2
View File
@@ -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'" ] ]
```