summaryrefslogtreecommitdiff
path: root/tex/context/base/lxml-aux.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2012-10-20 11:51:00 +0200
committerHans Hagen <pragma@wxs.nl>2012-10-20 11:51:00 +0200
commit7669c544a236c85d93bc2eba8fab2a0537d9e4bc (patch)
tree289f437212da7fdd92a9bec453ba6da0804f1106 /tex/context/base/lxml-aux.lua
parent06a1c5537e6643f260001bab92777dfcbaa3d00f (diff)
downloadcontext-7669c544a236c85d93bc2eba8fab2a0537d9e4bc.tar.gz
beta 2012.10.20 11:51
Diffstat (limited to 'tex/context/base/lxml-aux.lua')
-rw-r--r--tex/context/base/lxml-aux.lua43
1 files changed, 43 insertions, 0 deletions
diff --git a/tex/context/base/lxml-aux.lua b/tex/context/base/lxml-aux.lua
index be12659ba..053e49303 100644
--- a/tex/context/base/lxml-aux.lua
+++ b/tex/context/base/lxml-aux.lua
@@ -766,3 +766,46 @@ function xml.separate(x,pattern)
end
return x
end
+
+--
+
+local helpers = xml.helpers or { }
+xml.helpers = helpers
+
+local function normal(e,action)
+ local edt = e.dt
+ if edt then
+ for i=1,#edt do
+ local str = edt[i]
+ if type(str) == "string" and str ~= "" then
+ edt[i] = action(str)
+ end
+ end
+ end
+end
+
+local function recurse(e,action)
+ local edt = e.dt
+ if edt then
+ for i=1,#edt do
+ local str = edt[i]
+ if type(str) ~= "string" then
+ recurse(str,action,recursive)
+ elseif str ~= "" then
+ edt[i] = action(str)
+ end
+ end
+ end
+end
+
+function helpers.recursetext(collected,action,recursive)
+ if recursive then
+ for i=1,#collected do
+ recurse(collected[i],action)
+ end
+ else
+ for i=1,#collected do
+ normal(collected[i],action)
+ end
+ end
+end