diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-04-22 11:36:47 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-04-22 11:36:47 -0700 |
commit | 72bdac3036cdab7c7fa3b02b5c7ac8ee93350cef (patch) | |
tree | d9258fd9635808dc3f84487ac7f9498fd43a2011 /tools | |
parent | 873a4c4bf53d8bb4ab972acbb3e63113a431167d (diff) | |
download | pandoc-72bdac3036cdab7c7fa3b02b5c7ac8ee93350cef.tar.gz |
New README template, take in/out formats from manual.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/update-readme.lua | 48 |
1 files changed, 16 insertions, 32 deletions
diff --git a/tools/update-readme.lua b/tools/update-readme.lua index 4f77c59c2..eabaf2285 100644 --- a/tools/update-readme.lua +++ b/tools/update-readme.lua @@ -1,38 +1,22 @@ -- 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. +-- inserts contents of input-formats and output-formats + +local f = assert(io.open("MANUAL.txt", "r")) +local manual = f:read("*all") +mdoc = pandoc.read(manual, "markdown") +f:close() +result = {} 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 blocks[i].t == 'Header' then - include = false - end - 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' and - blocks[i].identifier == 'description' then - include = true - end - i = i + 1 - end - return pandoc.Div(description, pandoc.Attr("description",{},{})) + local ident = elem.identifier or "" + local get = function(el) + if el.identifier == ident then + result = el + end + end + if ident == 'input-formats' or ident == 'output-formats' then + pandoc.walk_block(pandoc.Div(mdoc.blocks), { Div = get }) + return result end end |