aboutsummaryrefslogtreecommitdiff
path: root/tools/extract-changes.hs
blob: d0ef35888fa3fb76e70c4b1b7d4039a9dee27abd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/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