diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-10-02 18:16:43 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-10-02 18:16:43 -0700 |
commit | d975917509061e4dfbeb4d2444f5ef7ccbe1887b (patch) | |
tree | ce5d3ee98104244ae45e8decdf34f5d3e6d05a65 /src/Text/Pandoc/Writers | |
parent | 7bf80575b5e13cff864720a93505b0fe4d620480 (diff) | |
download | pandoc-d975917509061e4dfbeb4d2444f5ef7ccbe1887b.tar.gz |
Removed Text.Pandoc.Groff.
Moved groffEscape function to Text.Pandoc.Writers.Shared.
[API change, since T.P.W.S is exported.]
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/Man.hs | 1 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Ms.hs | 1 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/Shared.hs | 11 |
3 files changed, 11 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs index c37d13841..81fa38bd7 100644 --- a/src/Text/Pandoc/Writers/Man.hs +++ b/src/Text/Pandoc/Writers/Man.hs @@ -45,7 +45,6 @@ import Text.Pandoc.Logging import Text.Pandoc.Options import Text.Pandoc.Pretty import Text.Pandoc.Shared -import Text.Pandoc.Groff (groffEscape) import Text.Pandoc.Templates import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared diff --git a/src/Text/Pandoc/Writers/Ms.hs b/src/Text/Pandoc/Writers/Ms.hs index 5eda77233..9a35a9693 100644 --- a/src/Text/Pandoc/Writers/Ms.hs +++ b/src/Text/Pandoc/Writers/Ms.hs @@ -60,7 +60,6 @@ import Text.Pandoc.Shared import Text.Pandoc.Templates import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared -import Text.Pandoc.Groff (groffEscape) import Text.Printf (printf) import Text.TeXMath (writeEqn) diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs index 438a35ca4..ccf39c3c8 100644 --- a/src/Text/Pandoc/Writers/Shared.hs +++ b/src/Text/Pandoc/Writers/Shared.hs @@ -44,6 +44,7 @@ module Text.Pandoc.Writers.Shared ( , gridTable , metaValueToInlines , stripLeadingTrailingSpace + , groffEscape ) where import Prelude @@ -63,6 +64,8 @@ import Text.Pandoc.Pretty import Text.Pandoc.Walk (query) import Text.Pandoc.UTF8 (toStringLazy) import Text.Pandoc.XML (escapeStringForXML) +import Text.Printf (printf) +import Data.Char (isAscii, ord) -- | Create JSON value for template from a 'Meta' and an association list -- of variables, specified at the command line or in the writer. @@ -340,3 +343,11 @@ metaValueToInlines (MetaInlines ils) = ils metaValueToInlines (MetaBlocks bs) = query return bs metaValueToInlines (MetaBool b) = [Str $ show b] metaValueToInlines _ = [] + +-- | Escape non-ASCII characters using groff \u[..] sequences. +groffEscape :: T.Text -> T.Text +groffEscape = T.concatMap toUchar + where toUchar c + | isAscii c = T.singleton c + | otherwise = T.pack $ printf "\\[u%04X]" (ord c) + |