summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/lxml-aux.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2020-03-26 22:27:51 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2020-03-26 22:27:51 +0100
commitd9aa299de0f736f75f90b98ab284e5bc73515949 (patch)
tree080ffe743d8cb15f2c6b8d4f3ca06219cff3228d /tex/context/base/mkiv/lxml-aux.lua
parent0b0256403b7e111df0ecdb8ca589f20df787dacd (diff)
downloadcontext-d9aa299de0f736f75f90b98ab284e5bc73515949.tar.gz
2020-03-26 21:49:00
Diffstat (limited to 'tex/context/base/mkiv/lxml-aux.lua')
-rw-r--r--tex/context/base/mkiv/lxml-aux.lua48
1 files changed, 42 insertions, 6 deletions
diff --git a/tex/context/base/mkiv/lxml-aux.lua b/tex/context/base/mkiv/lxml-aux.lua
index ed0f03fd8..67ee31c88 100644
--- a/tex/context/base/mkiv/lxml-aux.lua
+++ b/tex/context/base/mkiv/lxml-aux.lua
@@ -176,7 +176,7 @@ local function xmltoelement(whatever,root)
end
local element
if type(whatever) == "string" then
- element = xmlinheritedconvert(whatever,root) -- beware, not really a root
+ element = xmlinheritedconvert(whatever,root,true) -- beware, not really a root
else
element = whatever -- we assume a table
end
@@ -430,10 +430,10 @@ local function include(xmldata,pattern,attribute,recursive,loaddata,level)
-- for the moment hard coded
epdt[ek.ni] = xml.escaped(data) -- d[k] = xml.escaped(data)
else
-local settings = xmldata.settings
-local savedresource = settings.currentresource
-settings.currentresource = name
- local xi = xmlinheritedconvert(data,xmldata)
+ local settings = xmldata.settings
+ local savedresource = settings.currentresource
+ settings.currentresource = name
+ local xi = xmlinheritedconvert(data,xmldata,true)
if not xi then
epdt[ek.ni] = "" -- xml.empty(d,k)
else
@@ -443,7 +443,7 @@ settings.currentresource = name
local child = xml.body(xi) -- xml.assign(d,k,xi)
child.__p__ = ekrt
child.__f__ = name -- handy for tracing
-child.cf = name
+ child.cf = name
epdt[ek.ni] = child
local settings = xmldata.settings
local inclusions = settings and settings.inclusions
@@ -591,8 +591,44 @@ function xml.strip(root,pattern,nolines,anywhere) -- strips all leading and trai
stripelement(collected[i],nolines,anywhere)
end
end
+-- return root
end
+-- local function compactelement(e)
+-- local edt = e.dt
+-- if edt then
+-- local t = { }
+-- local m = 0
+-- for e=1,#edt do
+-- local str = edt[e]
+-- if type(str) ~= "string" then
+-- m = m + 1
+-- t[m] = str
+-- elseif str ~= "" and find(str,"%S") then
+-- m = m + 1
+-- t[m] = str
+-- end
+-- end
+-- e.dt = t
+-- end
+-- return e -- convenient
+-- end
+
+local function compactelement(e)
+ local edt = e.dt
+ if edt then
+ for e=1,#edt do
+ local str = edt[e]
+ if type(str) == "string" and not find(str,"%S") then
+ edt[e] = ""
+ end
+ end
+ end
+ return e -- convenient
+end
+
+xml.compactelement = compactelement
+
local function renamespace(root, oldspace, newspace) -- fast variant
local ndt = #root.dt
for i=1,ndt or 0 do