aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-12-29 16:41:51 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2017-12-29 16:41:51 -0800
commit81b0b208278ea8982d6581bda0dc922c466df2a9 (patch)
tree6f7d39e01586780dfd0400aa709e3dacd94fbe70 /tools
parent0d968c4bbbd9e9b718d6fa63814419866e670c95 (diff)
downloadpandoc-81b0b208278ea8982d6581bda0dc922c466df2a9.tar.gz
Generate README.md from template and MANUAL.txt.
`make README.md` will generate the README.md after changes to MANUAL.txt have been made.
Diffstat (limited to 'tools')
-rw-r--r--tools/update-readme.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/tools/update-readme.lua b/tools/update-readme.lua
new file mode 100644
index 000000000..916b80881
--- /dev/null
+++ b/tools/update-readme.lua
@@ -0,0 +1,38 @@
+-- update README.md based on MANUAL.txt
+-- assumes that the README.md has a div with id 'description'.
+-- this gets replaced by the contents of the 'description' section
+-- of the manual.
+
+function Div(elem)
+ if elem.classes[1] and elem.classes[1] == 'description' then
+ local f = assert(io.open("MANUAL.txt", "r"))
+ local manual = f:read("*all")
+ f:close()
+ local description = {}
+ local i = 1
+ local include = false
+ local mdoc = pandoc.read(manual, "markdown")
+ local blocks = mdoc.blocks
+ while blocks[i] do
+ if include then
+ table.insert(description, pandoc.walk_block(blocks[i],
+ -- remove internal links
+ { Link = function(el)
+ if el.target:match("^#") then
+ return el.content
+ end
+ end }))
+ end
+ if blocks[i].t == 'Header' then
+ if blocks[i].identifier == 'description' then
+ include = true
+ elseif include then
+ include = false
+ end
+ end
+ i = i + 1
+ end
+ return pandoc.Div(description, pandoc.Attr("description",{},{}))
+ end
+end
+