1 | module Goop.Pandoc.Process
6 | import Text.PrettyPrint.Bernardy
9 | import Goop.Pandoc.JSON
17 | Interpolation InputFormat where
18 | interpolate GFM = "gfm"
21 | parseDocument : HasIO io => (fmt : InputFormat) -> (path : String) -> io Pandoc
22 | parseDocument fmt path = do
23 | let pandoc_part = "pandoc -f \{fmt} -t json \{path}"
26 | "jq 'walk(if type == \"object\" and keys == [\"t\"] then . + {\"c\": null} else . end)'"
27 | let command = "\{pandoc_part} | \{jq_part}"
28 | Right pipe <- popen command Read
29 | | Left err => fail "Pandoc Call: \{show err}"
30 | Right output <- fRead pipe
31 | | Left err => fail "Pandoc Pipe: \{show err}"
32 | let res : DecodingResult Pandoc = decode output
33 | Right pandoc <- pure res
34 | | Left err => fail "Parsing pandoc output: \{show err}"
39 | [_, path] <- getArgs
40 | | xs => fail "Invalid augments: \{show xs}"
43 | putStrLn "Parsing document from \{path} as gfm"
44 | document <- parseDocument GFM path
45 | putStrLn $
render (Opts (cast cols)) (pretty document)