2017-11-18 22:33:37 +01:00
|
|
|
-- we use preloaded text to get a UTF-8 aware 'upper' function
|
|
|
|
local text = require('text')
|
2017-11-12 00:26:24 +01:00
|
|
|
|
2017-11-18 22:33:37 +01:00
|
|
|
-- capitalize level 1 headers
|
2017-11-12 00:26:24 +01:00
|
|
|
function Header(el)
|
|
|
|
if el.level == 1 then
|
|
|
|
return pandoc.walk_block(el, {
|
|
|
|
Str = function(el)
|
2017-11-18 22:33:37 +01:00
|
|
|
return pandoc.Str(text.upper(el.text))
|
2017-11-12 00:26:24 +01:00
|
|
|
end })
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-04-27 19:01:09 +02:00
|
|
|
-- For portability with mandoc, which doesn't allow man commands
|
|
|
|
-- inside table cells, we convert all tables to code blocks.
|
2022-01-30 00:35:37 +01:00
|
|
|
function Table(el)
|
2022-04-27 19:01:09 +02:00
|
|
|
local rendered = pandoc.write(pandoc.Pandoc({el}), "plain")
|
|
|
|
local adjusted = rendered -- tame grid table lines
|
|
|
|
:gsub("%+([=:][=:]+)",
|
|
|
|
function(s)
|
|
|
|
return " " .. string.rep("-", #s - 1)
|
|
|
|
end)
|
|
|
|
:gsub("(%+[-:][-:]+)",
|
|
|
|
function(s)
|
|
|
|
return ""
|
|
|
|
end)
|
|
|
|
:gsub("%+\n","\n")
|
|
|
|
:gsub("\n| ","\n|")
|
|
|
|
:gsub("|","")
|
|
|
|
return { pandoc.RawBlock("man", ".RS -14n"),
|
|
|
|
pandoc.CodeBlock(adjusted),
|
|
|
|
pandoc.RawBlock("man", ".RE") }
|
2022-01-30 00:35:37 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-11-18 22:33:37 +01:00
|
|
|
-- replace links with link text
|
2017-11-12 00:26:24 +01:00
|
|
|
function Link(el)
|
|
|
|
return el.content
|
|
|
|
end
|
|
|
|
|
2017-11-18 22:33:37 +01:00
|
|
|
-- remove notes
|
2017-11-12 00:26:24 +01:00
|
|
|
function Note(el)
|
|
|
|
return {}
|
|
|
|
end
|