diff options
Diffstat (limited to 'html.lua')
-rw-r--r-- | html.lua | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -19,7 +19,9 @@ local html local function fmt_tag(tag) local attrs = tag.attrs and fmt_attrs(tag.attrs) or "" local selfclosing = (tag.body == "") - local sameline = type(tag.body) == "string" or (type(tag.body) == "table" and tag.body.tag) + local sameline = type(tag.body) == "string" + or (type(tag.body) == "table" and tag.body.tag) + or (type(tag.body) == "table" and #tag.body <= 1) local maybenl = sameline and "" or "\n" if selfclosing then return ("<%s%s/>"):format(tag.tname,attrs) @@ -70,9 +72,13 @@ html = function (x) return safe( tostring(x) ) else -- just a regular list + local nl = "\n" + if #x <= 2 then + nl = "" + end local o = "" for _,item in ipairs(x) do - o = o .. tostring(html(item)) .. "\n" + o = o .. tostring(html(item)) .. nl end return safe(o) end |