summaryrefslogtreecommitdiff
path: root/tex/context/base/lxml-xml.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2012-05-22 02:40:13 +0300
committerMarius <mariausol@gmail.com>2012-05-22 02:40:13 +0300
commitffb360b52944514197aa47313c26816cd2fb7a7e (patch)
treeaf46811e825bb977838cd2db44646879f281b752 /tex/context/base/lxml-xml.lua
parent3821b4213bf250551cfa122313ae2c56f9923533 (diff)
downloadcontext-ffb360b52944514197aa47313c26816cd2fb7a7e.tar.gz
beta 2012.05.22 01:22
Diffstat (limited to 'tex/context/base/lxml-xml.lua')
-rw-r--r--tex/context/base/lxml-xml.lua42
1 files changed, 41 insertions, 1 deletions
diff --git a/tex/context/base/lxml-xml.lua b/tex/context/base/lxml-xml.lua
index 7e7922cfb..d0e256078 100644
--- a/tex/context/base/lxml-xml.lua
+++ b/tex/context/base/lxml-xml.lua
@@ -7,7 +7,7 @@ if not modules then modules = { } end modules ['lxml-xml'] = {
}
local concat = table.concat
-local find = string.find
+local find, lower, upper = string.find, string.lower, string.upper
local xml = xml
@@ -403,3 +403,43 @@ end
function xml.textonly(e) -- no pattern
return concat(textonly(e,{}))
end
+
+--
+
+-- local x = xml.convert("<x><a x='+'>1<B>2</B>3</a></x>")
+-- xml.filter(x,"**/lowerall()") print(x)
+-- xml.filter(x,"**/upperall()") print(x)
+
+function finalizers.lowerall(collected)
+ for c=1,#collected do
+ local e = collected[c]
+ if not e.special then
+ e.tg = lower(e.tg)
+ local eat = e.at
+ if eat then
+ local t = { }
+ for k,v in next, eat do
+ t[lower(k)] = v
+ end
+ e.at = t
+ end
+ end
+ end
+end
+
+function finalizers.upperall(collected)
+ for c=1,#collected do
+ local e = collected[c]
+ if not e.special then
+ e.tg = upper(e.tg)
+ local eat = e.at
+ if eat then
+ local t = { }
+ for k,v in next, eat do
+ t[upper(k)] = v
+ end
+ e.at = t
+ end
+ end
+ end
+end