diff options
author | Marius <mariausol@gmail.com> | 2011-08-26 03:00:14 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2011-08-26 03:00:14 +0300 |
commit | 6472806d2b22969e53d332eec7331d26099adb3d (patch) | |
tree | 85d5aaf103778505ec1028d1f2d0ff5a545004fc /tex/context/base/lxml-xml.lua | |
parent | 39820e8648b41ea8ce0ea7aeb7dec70be096baa6 (diff) | |
download | context-6472806d2b22969e53d332eec7331d26099adb3d.tar.gz |
beta 2011.08.26 01:43
Diffstat (limited to 'tex/context/base/lxml-xml.lua')
-rw-r--r-- | tex/context/base/lxml-xml.lua | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tex/context/base/lxml-xml.lua b/tex/context/base/lxml-xml.lua index 5012f69e5..05405015d 100644 --- a/tex/context/base/lxml-xml.lua +++ b/tex/context/base/lxml-xml.lua @@ -111,10 +111,10 @@ local function chainattribute(collected,arguments) -- todo: optional levels return "" end -local function raw(collected) -- hybrid +local function raw(collected) -- hybrid (not much different from text so it might go) if collected then local e = collected[1] or collected - return (e and xmlserialize(e)) or "" -- only first as we cannot concat function + return e and xmltostring(e) or "" -- only first as we cannot concat function else return "" end @@ -138,10 +138,15 @@ local xmltexthandler = xmlnewhandlers { } local function xmltotext(root) - if not root then + local dt = root.dt + if not dt then return "" - elseif type(root) == 'string' then - return root + end + local nt = #dt -- string or table + if nt == 0 then + return "" + elseif nt == 1 and type(dt[1]) == "string" then + return dt[1] -- no escaping of " ' < > & else return xmlserialize(root,xmltexthandler) or "" end @@ -152,7 +157,7 @@ end local function text(collected) -- hybrid if collected then local e = collected[1] or collected - return (e and xmltotext(e.dt)) or "" + return (e and xmltotext(e)) or "" else return "" end @@ -300,10 +305,10 @@ function xml.text(id,pattern) if pattern then -- return text(xmlfilter(id,pattern)) local collected = xmlfilter(id,pattern) - return (collected and xmltotext(collected[1].dt)) or "" + return (collected and xmltotext(collected[1])) or "" elseif id then -- return text(id) - return xmltotext(id.dt) or "" + return xmltotext(id) or "" else return "" end |