summaryrefslogtreecommitdiff
path: root/tex/context/base/lxml-mis.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/lxml-mis.lua')
-rw-r--r--tex/context/base/lxml-mis.lua41
1 files changed, 11 insertions, 30 deletions
diff --git a/tex/context/base/lxml-mis.lua b/tex/context/base/lxml-mis.lua
index a117b1af9..eff012013 100644
--- a/tex/context/base/lxml-mis.lua
+++ b/tex/context/base/lxml-mis.lua
@@ -18,7 +18,8 @@ this module. Since this module is also used in <l n='mtxrun'/> we've
put them here instead of loading mode modules there then needed.</p>
--ldx]]--
-function xml.gsub(t,old,new)
+
+local function xmlgsub(t,old,new)
local dt = t.dt
if dt then
for k=1,#dt do
@@ -26,26 +27,24 @@ function xml.gsub(t,old,new)
if type(v) == "string" then
dt[k] = gsub(v,old,new)
else
- xml.gsub(v,old,new)
+ xmlgsub(v,old,new)
end
end
end
end
+xmlgsub = xmlgsub
+
function xml.strip_leading_spaces(dk,d,k) -- cosmetic, for manual
- if d and k and d[k-1] and type(d[k-1]) == "string" then
- local s = d[k-1]:match("\n(%s+)")
- xml.gsub(dk,"\n"..string.rep(" ",#s),"\n")
+ if d and k then
+ local dkm = d[k-1]
+ if dkm and type(dkm) == "string" then
+ local s = match(dkm,"\n(%s+)")
+ xmlgsub(dk,"\n"..rep(" ",#s),"\n")
+ end
end
end
-function xml.serialize_path(root,lpath,handle)
- local dk, r, d, k = xml.first(root,lpath)
- dk = xml.copy(dk)
- xml.strip_leading_spaces(dk,d,k)
- xml.serialize(dk,handle)
-end
-
--~ xml.escapes = { ['&'] = '&amp;', ['<'] = '&lt;', ['>'] = '&gt;', ['"'] = '&quot;' }
--~ xml.unescapes = { } for k,v in pairs(xml.escapes) do xml.unescapes[v] = k end
@@ -71,8 +70,6 @@ local escaped = Cs(normal * (special * normal)^0)
-- 100 * 1000 * "oeps&lt; oeps&gt; oeps&amp;" : gsub:lpeg == 0153:0280:0151:0080 (last one by roberto)
--- unescaped = Cs((S("&lt;")/"<" + S("&gt;")/">" + S("&amp;")/"&" + 1)^0)
--- unescaped = Cs((((P("&")/"") * (P("lt")/"<" + P("gt")/">" + P("amp")/"&") * (P(";")/"")) + 1)^0)
local normal = (1 - S"&")^0
local special = P("&lt;")/"<" + P("&gt;")/">" + P("&amp;")/"&"
local unescaped = Cs(normal * (special * normal)^0)
@@ -88,19 +85,3 @@ xml.cleansed_pattern = cleansed
function xml.escaped (str) return escaped :match(str) end
function xml.unescaped(str) return unescaped:match(str) end
function xml.cleansed (str) return cleansed :match(str) end
-
-function xml.join(t,separator,lastseparator)
- if #t > 0 then
- local result = { }
- for k,v in pairs(t) do
- result[k] = xml.tostring(v)
- end
- if lastseparator then
- return concat(result,separator or "",1,#result-1) .. (lastseparator or "") .. result[#result]
- else
- return concat(result,separator)
- end
- else
- return ""
- end
-end