From 989f315a84bb17535d50f60b754acbf7bd969b8b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 29 Jan 2022 15:35:37 -0800 Subject: [PATCH] manfilter.lua: remove extra indent in table cells with code blocks. --- man/manfilter.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/man/manfilter.lua b/man/manfilter.lua index c6bbd02c4..dd1a9ab56 100644 --- a/man/manfilter.lua +++ b/man/manfilter.lua @@ -11,6 +11,30 @@ function Header(el) end end +-- unindent table content +function Table(el) + for _,body in ipairs(el.bodies) do + handleTableBody(body) + end + return el +end + +local function handleCell(el) + if #el.contents > 0 and el.contents[1].t == "CodeBlock" then + table.insert(el.contents, 1, pandoc.RawBlock("man", ".RS -14n")) + table.insert(el.contents, pandoc.RawBlock("man", ".RE")) + end +end + +function handleTableBody(el) + for _,row in ipairs(el.body) do + for _,cell in ipairs(row.cells) do + handleCell(cell) + end + end +end + + -- replace links with link text function Link(el) return el.content