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
This commit is contained in:
parent
a74010a051
commit
ea5cd35004
1 changed files with 7 additions and 0 deletions
|
@ -106,6 +106,7 @@ module Text.Pandoc
|
|||
, module Text.Pandoc.Templates
|
||||
-- * Version
|
||||
, pandocVersion
|
||||
, jsonFilter
|
||||
) where
|
||||
|
||||
import Text.Pandoc.Definition
|
||||
|
@ -190,3 +191,9 @@ writers = [("native" , writeNative)
|
|||
,("rtf" , writeRTF)
|
||||
,("org" , writeOrg)
|
||||
]
|
||||
|
||||
-- | Converts a transformation on the Pandoc AST into a function
|
||||
-- that reads and writes a JSON-encoded string. This is useful
|
||||
-- for writing small scripts.
|
||||
jsonFilter :: (Pandoc -> Pandoc) -> String -> String
|
||||
jsonFilter f = encodeJSON . f . decodeJSON
|
||||
|
|
Loading…
Add table
Reference in a new issue