summaryrefslogtreecommitdiff
path: root/build/extract-title.hs
blob: a84442e732737fe3146ab4b03b35878a11fa9c51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env runhaskell

import Text.Pandoc.Pretty
import Text.Pandoc.JSON
import System.IO

extract_title :: Pandoc -> IO Pandoc
extract_title d@(Pandoc m _) = do hPutStrLn stderr $ (++) "title: " $ render Nothing $ cat $ map pretty (docTitle m)
                                  return d
  where pretty :: Inline -> Doc
        pretty (Str s) = text s
        pretty Space = space
        pretty _ = empty

main :: IO ()
main = toJSONFilter extract_title