@@ -29,6 +29,7 @@ Parses command-line options and calls the appropriate readers and
2929writers.
3030-}
3131module Main where
32+import Text.JSON.Generic (encodeJSON, decodeJSON)
3233import Text.Pandoc
3334import Text.Pandoc.S5 (s5HeaderIncludes)
3435import Text.Pandoc.Shared ( tabFilter, ObfuscationMethod (..), readDataFile,
@@ -83,6 +84,7 @@ wrapWords c = wrap' c c where
8384-- | Association list of formats and readers.
8485readers :: [(String, ParserState -> String -> Pandoc)]
8586readers = [("native" , readPandoc)
87+ ,("json" , readJSON)
8688 ,("markdown" , readMarkdown)
8789 ,("markdown+lhs" , readMarkdown)
8890 ,("rst" , readRST)
@@ -97,9 +99,18 @@ readers = [("native" , readPandoc)
9799readPandoc :: ParserState -> String -> Pandoc
98100readPandoc _ = read
99101
102+-- | Reader for JSON version of Pandoc AST.
103+readJSON :: ParserState -> String -> Pandoc
104+readJSON _ = decodeJSON
105+
106+-- | Writer for JSON version of Pandoc AST.
107+writeJSON :: WriterOptions -> Pandoc -> String
108+writeJSON _ = encodeJSON
109+
100110-- | Association list of formats and writers.
101111writers :: [ ( String, WriterOptions -> Pandoc -> String ) ]
102112writers = [("native" , writeNative)
113+ ,("json" , writeJSON)
103114 ,("html" , writeHtmlString)
104115 ,("html+lhs" , writeHtmlString)
105116 ,("s5" , writeHtmlString)