aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-02-01 21:59:58 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2019-02-01 21:59:58 -0800
commitf5ebe98773e5b2de0d3cd2a87411b4141d0acd39 (patch)
treed8940cedc34a328936f3b556743ae233d1427616 /src/Text
parent20a0b4433f1fa72f921b5b660a43c221926634ec (diff)
downloadpandoc-f5ebe98773e5b2de0d3cd2a87411b4141d0acd39.tar.gz
LaTeX writer: code simplification in escaping.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 307e96993..619ad05a4 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -322,40 +322,41 @@ data StringContext = TextString
stringToLaTeX :: PandocMonad m => StringContext -> String -> LW m String
stringToLaTeX context zs = do
opts <- gets stOptions
- go opts context $
+ return $
+ go opts context $
if writerPreferAscii opts
then T.unpack $ Normalize.normalize Normalize.NFD $ T.pack zs
else zs
where
- go _ _ [] = return ""
- go opts ctx (x:xs) = do
+ go _ _ [] = ""
+ go opts ctx (x:xs) =
let ligatures = isEnabled Ext_smart opts && ctx == TextString
- let isUrl = ctx == URLString
- let mbAccentCmd =
+ isUrl = ctx == URLString
+ mbAccentCmd =
if writerPreferAscii opts && ctx == TextString
then uncons xs >>= \(c,_) -> M.lookup c accents
else Nothing
- let emits s =
+ emits s =
case mbAccentCmd of
- Just cmd -> ((cmd ++ "{" ++ s ++ "}") ++)
- <$> go opts ctx (drop 1 xs) -- drop combining accent
- Nothing -> (s++) <$> go opts ctx xs
- let emitc c =
+ Just cmd -> (cmd ++ "{" ++ s ++ "}") ++
+ go opts ctx (drop 1 xs) -- drop combining accent
+ Nothing -> s ++ go opts ctx xs
+ emitc c =
case mbAccentCmd of
- Just cmd -> ((cmd ++ "{" ++ [c] ++ "}") ++)
- <$> go opts ctx (drop 1 xs) -- drop combining accent
- Nothing -> (c:) <$> go opts ctx xs
- let emitcseq cs = do
- rest <- go opts ctx xs
+ Just cmd -> cmd ++ "{" ++ [c] ++ "}" ++
+ go opts ctx (drop 1 xs) -- drop combining accent
+ Nothing -> c : go opts ctx xs
+ emitcseq cs = do
+ let rest = go opts ctx xs
case rest of
c:_ | isLetter c
, ctx == TextString
- -> return (cs <> " " <> rest)
- | isSpace c -> return (cs <> "{}" <> rest)
+ -> cs <> " " <> rest
+ | isSpace c -> cs <> "{}" <> rest
| ctx == TextString
- -> return (cs <> rest)
- _ -> return (cs <> "{}" <> rest)
- case x of
+ -> cs <> rest
+ _ -> cs <> "{}" <> rest
+ in case x of
'{' -> emits "\\{"
'}' -> emits "\\}"
'`' | ctx == CodeString -> emitcseq "\\textasciigrave"