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'" ] ] ```