git.iko.soy/typeable/pandoc
on master help sign in
Added 'stringify' to Text.Pandoc.Shared.
044a9a6John MacFarlane
src/Text/Pandoc/Shared.hs+10
@@ -57,6 +57,7 @@ module Text.Pandoc.Shared (
57 -- * Pandoc block and inline list processing
57 -- * Pandoc block and inline list processing
58 orderedListMarkers,
58 orderedListMarkers,
59 normalizeSpaces,
59 normalizeSpaces,
60+ stringify,
60 compactify,
61 compactify,
61 Element (..),
62 Element (..),
62 hierarchicalize,
63 hierarchicalize,
@@ -340,6 +341,15 @@ normalizeSpaces list =
340 else lst
341 else lst
341 in removeLeading $ removeTrailing $ removeDoubles list
342 in removeLeading $ removeTrailing $ removeDoubles list
342
343
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+
343-- | Change final list item from @Para@ to @Plain@ if the list contains
353-- | Change final list item from @Para@ to @Plain@ if the list contains
344-- no other @Para@ blocks.
354-- no other @Para@ blocks.
345compactify :: [[Block]] -- ^ List of list items (each a list of blocks)
355compactify :: [[Block]] -- ^ List of list items (each a list of blocks)