diff options
Diffstat (limited to 'build/extract-title.hs')
-rwxr-xr-x | build/extract-title.hs | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/build/extract-title.hs b/build/extract-title.hs deleted file mode 100755 index 6964d26..0000000 --- a/build/extract-title.hs +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
1 | #!/usr/bin/env runhaskell | ||
2 | |||
3 | -- import Text.Pandoc.Pretty | ||
4 | -- import Text.Pandoc.JSON | ||
5 | import Text.Pandoc.Pretty | ||
6 | import Text.Pandoc.JSON | ||
7 | import qualified Text.Pandoc.Walk as W | ||
8 | import System.IO | ||
9 | import qualified Data.Aeson as A | ||
10 | import qualified Data.ByteString.Lazy as BL | ||
11 | |||
12 | extract_title :: Pandoc -> String | ||
13 | extract_title (Pandoc m _) = do | ||
14 | title <- render Nothing $ cat $ map pretty (docTitle m) | ||
15 | return title | ||
16 | where pretty :: Inline -> Doc | ||
17 | pretty (Str s) = text s | ||
18 | pretty Space = space | ||
19 | pretty _ = empty | ||
20 | |||
21 | main :: IO () | ||
22 | main = do | ||
23 | input <- BL.getContents | ||
24 | let title = (W.query extract_title :: Pandoc -> String) . either error id . A.eitherDecode' $ input | ||
25 | putStrLn title | ||