Convert tool/extract-changes.hs to a Lua filter.
This commit is contained in:
parent
6ffc489395
commit
0f80284c3d
3 changed files with 19 additions and 16 deletions
2
Makefile
2
Makefile
|
@ -75,7 +75,7 @@ fix_spacing: ## Fix trailing newlines and spaces
|
|||
for f in $(SOURCEFILES); do printf '%s\n' "`cat $$f`" | sed -e 's/ *$$//' > $$f.tmp; mv $$f.tmp $$f; done
|
||||
|
||||
changes_github: ## copy this release's changes in gfm
|
||||
pandoc --filter tools/extract-changes.hs changelog.md -t gfm --wrap=none --template tools/changes_template.html | sed -e 's/\\#/#/g' | pbcopy
|
||||
pandoc --lua-filter tools/extract-changes.lua changelog.md -t gfm --wrap=none --template tools/changes_template.html | sed -e 's/\\#/#/g' | pbcopy
|
||||
|
||||
|
||||
debpkg: ## create linux package
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
#!/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
|
18
tools/extract-changes.lua
Normal file
18
tools/extract-changes.lua
Normal file
|
@ -0,0 +1,18 @@
|
|||
-- Extract changes from latest version in changelog.
|
||||
|
||||
function Pandoc(el)
|
||||
local newblocks = {}
|
||||
i = 1
|
||||
while i <= #el.blocks and
|
||||
not (el.blocks[i].t == "Header" and el.blocks[i].level == 2) do
|
||||
i = i+1
|
||||
end
|
||||
while i <= #el.blocks do
|
||||
i = i+1
|
||||
if el.blocks[i].t == "Header" and el.blocks[i].level == 2 then
|
||||
break
|
||||
end
|
||||
table.insert(newblocks, el.blocks[i])
|
||||
end
|
||||
return pandoc.Pandoc(newblocks)
|
||||
end
|
Loading…
Reference in a new issue