git.iko.soy/typeable/pandoc
on master help sign in
Added 'stringify' to Text.Pandoc.Shared.
commit044a9a61574ff1414b44e2f92307996cba00a2e1 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 27 Nov 2010, 07:08 (16 years ago) parent0ca84f0
1 file changed+10
src/Text/Pandoc/Shared.hs+10
src/Text/Pandoc/Shared.hs+10
@@ -57,6 +57,7 @@ module Text.Pandoc.Shared (
5757 -- * Pandoc block and inline list processing
5858 orderedListMarkers,
5959 normalizeSpaces,
60+ stringify,
6061 compactify,
6162 Element (..),
6263 hierarchicalize,
@@ -340,6 +341,15 @@ normalizeSpaces list =
340341 else lst
341342 in removeLeading $ removeTrailing $ removeDoubles list
342343
344+-- | Convert list of inlines to a string with formatting removed.
345+stringify :: [Inline] -> String
346+stringify = queryWith go
347+ where go :: Inline -> [Char]
348+ go Space = " "
349+ go (Str x) = x
350+ go (Code x) = x
351+ go _ = ""
352+
343353-- | Change final list item from @Para@ to @Plain@ if the list contains
344354-- no other @Para@ blocks.
345355compactify :: [[Block]] -- ^ List of list items (each a list of blocks)