pandoc/tools/extract-changes.hs
2019-11-22 09:42:04 -08:00

15 lines
419 B
Haskell
Executable file

#!/usr/bin/env stack
-- stack --stack-yaml=stack.yaml runghc --package pandoc-types
-- Extract changes from latest version in changelog.
import Text.Pandoc.JSON
main = toJSONFilter extractFirst
extractFirst :: Pandoc -> Pandoc
extractFirst (Pandoc meta bs) =
let bs' = dropWhile (not . isSubhead) bs
in Pandoc meta (takeWhile (not . isSubhead) (drop 1 bs'))
isSubhead (Header 2 _ _) = True
isSubhead _ = False