blob: 4f77c59c29c85a45af2d1d24d2e1c53faa165d24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 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",{},{}))
end
end
|