From 06eb95d9c190e461228205b160c7ecf50220c521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= Date: Thu, 21 Nov 2024 06:54:16 +0100 Subject: [PATCH] Improve pretty-printing for text-only nodes --- luamml-xmlwriter.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/luamml-xmlwriter.lua b/luamml-xmlwriter.lua index a2b5abe..6880074 100644 --- a/luamml-xmlwriter.lua +++ b/luamml-xmlwriter.lua @@ -34,6 +34,10 @@ local function write_elem(tree, indent) return out .. '/>' end 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 is_string for _, elem in ipairs(tree) do