summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/xmllib.lua28
1 files changed, 23 insertions, 5 deletions
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 "<!-- " .. v.nodes[1] .. " -->"
elseif v.type == "lf" then
return "\n"