diff options
Diffstat (limited to 'build/extract-title.hs')
-rwxr-xr-x | build/extract-title.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/build/extract-title.hs b/build/extract-title.hs new file mode 100755 index 0000000..f3ca1ba --- /dev/null +++ b/build/extract-title.hs | |||
@@ -0,0 +1,16 @@ | |||
1 | #!/usr/bin/env runhaskell | ||
2 | |||
3 | import Text.Pandoc.Pretty | ||
4 | import Text.Pandoc.JSON | ||
5 | import System.IO | ||
6 | |||
7 | extract_title :: Pandoc -> IO Pandoc | ||
8 | extract_title d@(Pandoc m _) = do hPutStrLn stderr $ render Nothing $ cat $ map pretty (docTitle m) | ||
9 | return d | ||
10 | where pretty :: Inline -> Doc | ||
11 | pretty (Str s) = text s | ||
12 | pretty Space = space | ||
13 | pretty _ = empty | ||
14 | |||
15 | main :: IO () | ||
16 | main = toJSONFilter extract_title | ||