1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-12-22 07:38:52 -05:00

tools/2xep.lua: Fix <code> elements having unsupported attributes

The XEP DTD only supports a single attribute for <code>, 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.
This commit is contained in:
Matthew Wild 2023-06-28 16:15:34 +01:00
parent 56dd1cf33e
commit 88817709d3

View File

@ -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 "<example><![CDATA[".. s .. "]]></example>"
else
return "<code"..attributes(attr).."><![CDATA[".. s .. "]]></code>"
return "<code><![CDATA[".. s .. "]]></code>"
end
end