Improve pretty-printing for text-only nodes

This commit is contained in:
Marcel Fabian Krüger 2024-11-21 06:54:16 +01:00
parent b738939001
commit 06eb95d9c1

View File

@ -34,6 +34,10 @@ local function write_elem(tree, indent)
return out .. '/>' return out .. '/>'
end end
out = out .. '>' out = out .. '>'
-- Never indent the content if it's purely text.
if #tree == 1 and type(tree[1]) == 'string' then
indent = nil
end
local inner_indent = indent and indent .. ' ' local inner_indent = indent and indent .. ' '
local is_string local is_string
for _, elem in ipairs(tree) do for _, elem in ipairs(tree) do