git.iko.soy/typeable/pandoc
on master help sign in
Text.Pandoc: Added jsonFilter for easy construction of scripts.

Here's an example of its use: -- removelinks.hs - removes links from document import Text.Pandoc main = interact $ jsonFilter $ bottomUp removeLink removeLink :: Inline -> Inline removeLink (Link xs _) = Emph xs removeLink x = x

commitea5cd350042f31a66ee0d59e885d34598f9cc5a1 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 22 Jan 2011, 17:52 (16 years ago) parenta74010a
1 file changed+7
src/Text/Pandoc.hs+7
src/Text/Pandoc.hs+7
@@ -106,6 +106,7 @@ module Text.Pandoc
106106 , module Text.Pandoc.Templates
107107 -- * Version
108108 , pandocVersion
109+ , jsonFilter
109110 ) where
110111
111112import Text.Pandoc.Definition
@@ -190,3 +191,9 @@ writers = [("native" , writeNative)
190191 ,("rtf" , writeRTF)
191192 ,("org" , writeOrg)
192193 ]
194+
195+-- | Converts a transformation on the Pandoc AST into a function
196+-- that reads and writes a JSON-encoded string. This is useful
197+-- for writing small scripts.
198+jsonFilter :: (Pandoc -> Pandoc) -> String -> String
199+jsonFilter f = encodeJSON . f . decodeJSON