diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-10-18 09:39:55 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-10-18 09:39:55 -0700 |
commit | bbd94eae2b3f5273bb681ff6706f0cd375d8a1ef (patch) | |
tree | 224923b3a121b368e44e6f4315e39b644de52ef0 /src/Text/Pandoc/Writers | |
parent | 24f388e1a7ea4a6affad232035526191e5df961d (diff) | |
download | pandoc-bbd94eae2b3f5273bb681ff6706f0cd375d8a1ef.tar.gz |
Add Text.Pandoc.GroffChar.
This will hold common escaping data for groff characters.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/Groff.hs | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/src/Text/Pandoc/Writers/Groff.hs b/src/Text/Pandoc/Writers/Groff.hs index cb7252726..3f90a1490 100644 --- a/src/Text/Pandoc/Writers/Groff.hs +++ b/src/Text/Pandoc/Writers/Groff.hs @@ -51,6 +51,7 @@ import Text.Pandoc.Class (PandocMonad) import Text.Pandoc.Definition import Text.Pandoc.Pretty import Text.Printf (printf) +import Text.Pandoc.GroffChar (essentialEscapes) data WriterState = WriterState { stHasInlineMath :: Bool , stFirstPara :: Bool @@ -81,28 +82,9 @@ type Note = [Block] type MS = StateT WriterState --- | Association list of characters to escape. -groffEscapes :: Map.Map Char String -groffEscapes = Map.fromList - [ ('\160', "\\~") - , ('\'', "\\[aq]") - , ('`', "\\`") - , ('"', "\\[dq]") - , ('\x201C', "\\[lq]") - , ('\x201D', "\\[rq]") - , ('\x2018', "\\[oq]") - , ('\x2019', "\\[cq]") - , ('\x2014', "\\[em]") - , ('\x2013', "\\[en]") - , ('\x2026', "\\&...") - , ('~', "\\[ti]") - , ('^', "\\[ha]") - , ('@', "\\[at]") - , ('\\', "\\\\") - ] escapeChar :: Char -> String -escapeChar c = fromMaybe [c] (Map.lookup c groffEscapes) +escapeChar c = fromMaybe [c] (Map.lookup c essentialEscapes) -- | Escape special characters for groff. escapeString :: String -> String |