aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2010-11-27 07:08:06 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2010-11-27 07:08:06 -0800
commit044a9a61574ff1414b44e2f92307996cba00a2e1 (patch)
treeb4371ca5bfb7857fda676b53aee60246006ece72 /src/Text
parent0ca84f0d381639ca996eb037c9c4057b2de4ed2f (diff)
downloadpandoc-044a9a61574ff1414b44e2f92307996cba00a2e1.tar.gz
Added 'stringify' to Text.Pandoc.Shared.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Shared.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index 6cc48b88c..f2f38519b 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -57,6 +57,7 @@ module Text.Pandoc.Shared (
-- * Pandoc block and inline list processing
orderedListMarkers,
normalizeSpaces,
+ stringify,
compactify,
Element (..),
hierarchicalize,
@@ -340,6 +341,15 @@ normalizeSpaces list =
else lst
in removeLeading $ removeTrailing $ removeDoubles list
+-- | Convert list of inlines to a string with formatting removed.
+stringify :: [Inline] -> String
+stringify = queryWith go
+ where go :: Inline -> [Char]
+ go Space = " "
+ go (Str x) = x
+ go (Code x) = x
+ go _ = ""
+
-- | Change final list item from @Para@ to @Plain@ if the list contains
-- no other @Para@ blocks.
compactify :: [[Block]] -- ^ List of list items (each a list of blocks)