Functions for serializing the Pandoc AST to JSON and deserializing
from JSON.
Example of use: The following script (
capitalize.hs) reads
reads a JSON representation of a Pandoc document from stdin, and
writes a JSON representation of a Pandoc document to stdout. It
changes all regular text in the document to uppercase, without
affecting URLs, code, tags, etc. Run the script with
pandoc -t json | runghc capitalize.hs | pandoc -f json
or (making capitalize.hs executable)
pandoc --filter ./capitalize.hs
#!/usr/bin/env runghc
import Text.Pandoc.JSON
import Data.Char (toUpper)
main :: IO ()
main = toJSONFilter capitalizeStrings
capitalizeStrings :: Inline -> Inline
capitalizeStrings (Str s) = Str $ map toUpper s
capitalizeStrings x = x