git.iko.soy/typeable/pandoc
on master help sign in
Text.Pandoc: Added jsonFilter for easy construction of scripts.
ea5cd35John MacFarlane
src/Text/Pandoc.hs+7
@@ -106,6 +106,7 @@ module Text.Pandoc
106 , module Text.Pandoc.Templates
106 , module Text.Pandoc.Templates
107 -- * Version
107 -- * Version
108 , pandocVersion
108 , pandocVersion
109+ , jsonFilter
109 ) where
110 ) where
110
111
111import Text.Pandoc.Definition
112import Text.Pandoc.Definition
@@ -190,3 +191,9 @@ writers = [("native" , writeNative)
190 ,("rtf" , writeRTF)
191 ,("rtf" , writeRTF)
191 ,("org" , writeOrg)
192 ,("org" , writeOrg)
192 ]
193 ]
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