19 lines
499 B
Haskell
Executable File
19 lines
499 B
Haskell
Executable File
#!/usr/bin/env runhaskell
|
|
-- filter.hs
|
|
import Text.Pandoc.JSON
|
|
import qualified Data.Text.IO as TIO
|
|
import qualified Data.Text as T
|
|
|
|
file2Block :: FilePath -> IO [Block]
|
|
|
|
|
|
doInclude :: Block -> IO Block
|
|
doInclude cb@(Div (id, classes, namevals) contents) =
|
|
case lookup (T.pack "include") namevals of
|
|
Just f -> Div (id, classes, namevals) <$>
|
|
file2Block (T.unpack f)
|
|
Nothing -> return cb
|
|
doInclude x = return x
|
|
|
|
main :: IO ()
|
|
main = toJSONFilter doInclude |