jgm / pandocfilters

A python module for writing pandoc filters, with a collection of examples
BSD 3-Clause "New" or "Revised" License
512 stars 111 forks source link

Added includes examples from pandoc scripting page #3

Closed simonlau closed 3 years ago

simonlau commented 11 years ago

Added a converted python example of "include" from the pandoc scripting page

#!/usr/bin/env runhaskell
-- includes.hs
import Text.Pandoc.JSON

doInclude :: Block -> IO Block
doInclude cb@(CodeBlock (id, classes, namevals) contents) =
  case lookup "include" namevals of
       Just f     -> return . (CodeBlock (id, classes, namevals)) =<< readFile f
       Nothing    -> return cb
doInclude x = return x

main :: IO ()
main = toJSONFilter doInclude
jgm commented 10 years ago

Do you want to update your pull request with the correct code you quote above? You should also add it to the examples section of the README.