aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-10-03 17:36:32 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-10-03 17:36:32 -0700
commitd7263a7e5fb1ba53465099c6f1be7a85e05564f8 (patch)
tree88671309843066c59685de85c56bad1ce5738cb7
parentecd4d5b8d8cfda6a2cd8d8fb631e0d7c79bee363 (diff)
downloadpandoc-d7263a7e5fb1ba53465099c6f1be7a85e05564f8.tar.gz
Text.Pandoc.Writers.Shared: added `metaValueToString`.
[API change]
-rw-r--r--src/Text/Pandoc/Writers/Shared.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs
index ccf39c3c8..6113b0a66 100644
--- a/src/Text/Pandoc/Writers/Shared.hs
+++ b/src/Text/Pandoc/Writers/Shared.hs
@@ -43,6 +43,7 @@ module Text.Pandoc.Writers.Shared (
, unsmartify
, gridTable
, metaValueToInlines
+ , metaValueToString
, stripLeadingTrailingSpace
, groffEscape
)
@@ -61,6 +62,7 @@ import qualified Text.Pandoc.Builder as Builder
import Text.Pandoc.Definition
import Text.Pandoc.Options
import Text.Pandoc.Pretty
+import Text.Pandoc.Shared (stringify)
import Text.Pandoc.Walk (query)
import Text.Pandoc.UTF8 (toStringLazy)
import Text.Pandoc.XML (escapeStringForXML)
@@ -344,6 +346,13 @@ metaValueToInlines (MetaBlocks bs) = query return bs
metaValueToInlines (MetaBool b) = [Str $ show b]
metaValueToInlines _ = []
+metaValueToString :: MetaValue -> String
+metaValueToString (MetaString s) = s
+metaValueToString (MetaInlines ils) = stringify ils
+metaValueToString (MetaBlocks bs) = stringify bs
+metaValueToString (MetaBool b) = show b
+metaValueToString _ = ""
+
-- | Escape non-ASCII characters using groff \u[..] sequences.
groffEscape :: T.Text -> T.Text
groffEscape = T.concatMap toUchar