From 56dd1cf33e0ea6d80191b8bca56bf911595aa44f Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 28 Jun 2023 16:14:21 +0100 Subject: [PATCH 1/3] tools/2xep.lua: Fix incorrect order of section close tags --- tools/2xep.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/2xep.lua b/tools/2xep.lua index 34c46902..cdf8b8fd 100644 --- a/tools/2xep.lua +++ b/tools/2xep.lua @@ -126,7 +126,7 @@ function Doc(body, metadata, variables) end add(""); add(body) - for i = 1, #sectionstack do + for i = #sectionstack, 1, -1 do add(""); end add("\n"); From 88817709d3a64453ffd0b4e9f9a03d44aaa9df16 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 28 Jun 2023 16:15:34 +0100 Subject: [PATCH 2/3] tools/2xep.lua: Fix elements having unsupported attributes The XEP DTD only supports a single attribute for , the 'caption' attribute. I don't know if/how it's possible to attach a caption in markdown, so I'm leaving that as unsupported. That means no attributes are supported, and therefore I've removed them. Usage of ```xml is common, so I've also added code to handle those and convert them to example blocks. --- tools/2xep.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/2xep.lua b/tools/2xep.lua index cdf8b8fd..83a06b3f 100644 --- a/tools/2xep.lua +++ b/tools/2xep.lua @@ -286,10 +286,10 @@ local function has(haystack, needle) --> boolean end function CodeBlock(s, attr) - if attr and attr.class and has(attr.class, "example") then + if attr and attr.class and (has(attr.class, "example") or has(attr.class, "xml")) then return "" else - return "" + return "" end end From f2b88f03ce30c1e02e87f469bce92d019b09e81f Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 28 Jun 2023 16:20:17 +0100 Subject: [PATCH 3/3] tools/2xep.lua: emit instead of XEPs don't use . --- tools/2xep.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/2xep.lua b/tools/2xep.lua index 83a06b3f..4a6e0b95 100644 --- a/tools/2xep.lua +++ b/tools/2xep.lua @@ -95,8 +95,11 @@ function Doc(body, metadata, variables) local first, last = sv:match("(%S+)%s+(%S+)"); -- Names are hard add(("%s"):format(first)); add(("%s"):format(last)); - -- Why is there HTML in the thing? - for typ, addr in sv:gmatch("%shref='(%a+):([^']+)") do + -- The values have already be converted to the output format. + -- This means author entries with e.g. will already + -- have been converted into by the + -- Link() function. Hence this hacky parser to get back the original info. + for typ, addr in sv:gmatch("%surl='(%a+):([^']+)") do if typ == "mailto" then add(("%s"):format(addr)); elseif typ == "xmpp" then @@ -180,8 +183,7 @@ function Strikeout(s) end function Link(s, src, tit, attr) - return "" .. s .. "" + return "" .. s .. "" end function Image(s, src, tit, attr)