diff options
author | pixel <pixel> | 2007-05-30 06:59:13 +0000 |
---|---|---|
committer | pixel <pixel> | 2007-05-30 06:59:13 +0000 |
commit | 24f1125550a170438e283a4c52805baca273f99f (patch) | |
tree | c88de6590603095c278b7f762a4891772d5e0dec /lib | |
parent | dfcef1f768388e5eb859426e6e1e0d0bb8a4c65c (diff) |
Possibility of including handles into the XML tree.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/xmllib.lua | 28 |
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" |