diff options
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX.hs')
| -rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 03d258545..04a2ec801 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -343,6 +343,12 @@ inlineCommands = M.unions , biblatexInlineCommands tok , rest ] where + disableLigatures p = do + oldLigatures <- sLigatures <$> getState + updateState (\s -> s{ sLigatures = False }) + res <- p + updateState (\s -> s{ sLigatures = oldLigatures }) + pure res rest = M.fromList [ ("emph", extractSpaces emph <$> tok) , ("textit", extractSpaces emph <$> tok) @@ -352,7 +358,7 @@ inlineCommands = M.unions , ("textmd", extractSpaces (spanWith ("",["medium"],[])) <$> tok) , ("textrm", extractSpaces (spanWith ("",["roman"],[])) <$> tok) , ("textup", extractSpaces (spanWith ("",["upright"],[])) <$> tok) - , ("texttt", formatCode nullAttr <$> tok) + , ("texttt", formatCode nullAttr <$> disableLigatures tok) , ("alert", skipopts >> spanWith ("",["alert"],[]) <$> tok) -- beamer , ("textsuperscript", extractSpaces superscript <$> tok) , ("textsubscript", extractSpaces subscript <$> tok) @@ -634,6 +640,7 @@ inline = do do eatOneToken report $ ParsingUnescaped t pos return $ str t + ligatures <- sLigatures <$> getState case toktype of Comment -> mempty <$ eatOneToken Spaces -> space <$ eatOneToken @@ -641,14 +648,19 @@ inline = do Word -> str t <$ eatOneToken Symbol -> case t of - "-" -> eatOneToken *> + "-" | ligatures + -> eatOneToken *> option (str "-") (symbol '-' *> option (str "–") (str "—" <$ symbol '-')) "'" -> eatOneToken *> - option (str "’") (str "”" <$ symbol '\'') + option (str "’") (str "”" <$ (guard ligatures *> symbol '\'')) "~" -> str "\160" <$ eatOneToken - "`" -> doubleQuote <|> singleQuote <|> symbolAsString - "\"" -> doubleQuote <|> singleQuote <|> symbolAsString + "`" | ligatures + -> doubleQuote <|> singleQuote <|> (str "‘" <$ symbol '`') + | otherwise + -> str "‘" <$ symbol '`' + "\"" | ligatures + -> doubleQuote <|> singleQuote <|> symbolAsString "“" -> doubleQuote <|> symbolAsString "‘" -> singleQuote <|> symbolAsString "$" -> dollarsMath <|> unescapedSymbolAsString |
