aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-02-28 21:43:11 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2021-02-28 21:43:11 -0800
commit2463fbf61d2ea8636e70c44624dc5bc1668fa4fd (patch)
tree18333eba02a599250eb921cbb15ca68877347a5c /src/Text/Pandoc/Writers
parentd2bb0c7c8d599e6cd2aaef787b207bbfa66d4b9e (diff)
downloadpandoc-2463fbf61d2ea8636e70c44624dc5bc1668fa4fd.tar.gz
LaTeX writer: use function instead of map for accent lookup.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs52
1 files changed, 25 insertions, 27 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index e8a187599..e31ec9d52 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -262,7 +262,7 @@ stringToLaTeX context zs = do
isUrl = ctx == URLString
mbAccentCmd =
if writerPreferAscii opts && ctx == TextString
- then uncons xs >>= \(c,_) -> M.lookup c accents
+ then uncons xs >>= \(c,_) -> lookupAccent c
else Nothing
emits s =
case mbAccentCmd of
@@ -350,32 +350,30 @@ stringToLaTeX context zs = do
_ -> emitc x
| otherwise -> emitc x
-accents :: M.Map Char String
-accents = M.fromList
- [ ('\779' , "\\H")
- , ('\768' , "\\`")
- , ('\769' , "\\'")
- , ('\770' , "\\^")
- , ('\771' , "\\~")
- , ('\776' , "\\\"")
- , ('\775' , "\\.")
- , ('\772' , "\\=")
- , ('\781' , "\\|")
- , ('\817' , "\\b")
- , ('\807' , "\\c")
- , ('\783' , "\\G")
- , ('\777' , "\\h")
- , ('\803' , "\\d")
- , ('\785' , "\\f")
- , ('\778' , "\\r")
- , ('\865' , "\\t")
- , ('\782' , "\\U")
- , ('\780' , "\\v")
- , ('\774' , "\\u")
- , ('\808' , "\\k")
- , ('\785' , "\\newtie")
- , ('\8413', "\\textcircled")
- ]
+lookupAccent :: Char -> Maybe String
+lookupAccent '\779' = Just "\\H"
+lookupAccent '\768' = Just "\\`"
+lookupAccent '\769' = Just "\\'"
+lookupAccent '\770' = Just "\\^"
+lookupAccent '\771' = Just "\\~"
+lookupAccent '\776' = Just "\\\""
+lookupAccent '\775' = Just "\\."
+lookupAccent '\772' = Just "\\="
+lookupAccent '\781' = Just "\\|"
+lookupAccent '\817' = Just "\\b"
+lookupAccent '\807' = Just "\\c"
+lookupAccent '\783' = Just "\\G"
+lookupAccent '\777' = Just "\\h"
+lookupAccent '\803' = Just "\\d"
+lookupAccent '\785' = Just "\\f"
+lookupAccent '\778' = Just "\\r"
+lookupAccent '\865' = Just "\\t"
+lookupAccent '\782' = Just "\\U"
+lookupAccent '\780' = Just "\\v"
+lookupAccent '\774' = Just "\\u"
+lookupAccent '\808' = Just "\\k"
+lookupAccent '\8413' = Just "\\textcircled"
+lookupAccent _ = Nothing
toLabel :: PandocMonad m => Text -> LW m Text
toLabel z = go `fmap` stringToLaTeX URLString z