Something like this should work? The change to attributes() is a hack to use 'data-scale' rather than 'scale' and the change to Image() is to insert the alt text and the attributes. The main change is the new Figure() function (oops... I see that I'm ignoring its attributes).
% git diff -w
diff --git a/confluence.lua b/confluence.lua
index 3057d10..1a7d8ef 100644
--- a/confluence.lua
+++ b/confluence.lua
@@ -38,7 +38,9 @@ local function attributes(attr)
local attr_table = {}
for x,y in pairs(attr) do
if y and y ~= "" then
- table.insert(attr_table, ' ' .. x .. '="' .. escape(y,true) .. '"')
+ local p = ""
+ if x == "scale" then p = "data-" end
+ table.insert(attr_table, ' ' .. p .. x .. '="' .. escape(y,true) .. '"')
end
end
return table.concat(attr_table)
@@ -162,7 +164,7 @@ end
function Image(s, src, tit, attr)
return "<img src='" .. escape(src,true) .. "' title='" ..
- escape(tit,true) .. "'/>"
+ escape(tit,true) .. "' alt='" .. s .. "'" .. attributes(attr) .. "/>"
end
function Code(s, attr)
@@ -330,6 +332,14 @@ function CaptionedImage(src, tit, caption, attr)
return Div('<table><tbody><tr><td><ac:image><ri:attachment ri:filename="' .. escape(src,true) .. '" /></ac:image></td></tr><tr><td>' .. escape(caption) .. '</td></tr></tbody></table>', attr_cpy)
end
+
+function Figure(caption, image, attr)
+ local figcaption = '<figcaption aria-hidden="true">' ..
+ caption .. "</figcaption>"
+ return "<figure>\n" .. image .. "\n" .. figcaption .. "\n" .. "</figure>"
+end
+
+
-- Caption is a string, aligns is an array of strings,
-- widths is an array of floats, headers is an array of
-- strings, rows is an array of arrays of strings.
@@ -411,4 +421,3 @@ meta.__index =
return function() return "" end
end
setmetatable(_G, meta)
-