From 24f1125550a170438e283a4c52805baca273f99f Mon Sep 17 00:00:00 2001 From: pixel Date: Wed, 30 May 2007 06:59:13 +0000 Subject: Possibility of including handles into the XML tree. --- lib/xmllib.lua | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/xmllib.lua b/lib/xmllib.lua index 114dc08..27f36a0 100644 --- a/lib/xmllib.lua +++ b/lib/xmllib.lua @@ -65,7 +65,15 @@ end local function process_tag(xm, key, a) local ret, attrs, nodes, has_nodes, has_attrs, k, v, b = { istop = true, key = key }, {}, {}, false, false - if type(a) == "table" then + if type(a) == "string" then + a = { a } + end + + if type(a) ~= "table" then + error "Wrong argument type." + end + + if a.__objname == nil then for k, v in ipairs(a) do if type(v) == "table" then burrow(v) @@ -84,9 +92,13 @@ local function process_tag(xm, key, a) attrs[k] = attribute_escape(xml_escape(v)) end end - elseif type(a) == "string" then - has_nodes = true - table.insert(nodes, xml_escape(a)) + else + if a.__objname == "Handle" then + has_nodes = true + table.insert(nodes, a) + else + error "Can't handle objects which are not Handles." + end end if (has_nodes) then ret.nodes = nodes end @@ -114,7 +126,13 @@ end local function do_render_r(v) local middle, i, n = "" - if v.type == "comment" then + if v.__objname == "Handle" then + local r = "" + while not v.isclosed() do + r = r .. v.read() .. "\n" + end + return r + elseif v.type == "comment" then return "" elseif v.type == "lf" then return "\n" -- cgit v1.2.3