mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-26 01:15:53 +00:00
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:
co-authored by
Claude
parent
ce060e98e6
commit
63a1710cd4
@@ -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
|
||||
|
||||
@@ -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}" =?>
|
||||
|
||||
@@ -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'" ] ]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user