summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua42
1 files changed, 42 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua b/Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua
new file mode 100644
index 00000000000..921f971eb2e
--- /dev/null
+++ b/Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua
@@ -0,0 +1,42 @@
+module(...,package.seeall)
+
+
+function makeTag(s)
+ return "<"..s.."[^>]*>"
+end
+function matchTag(tg)
+ return makeTag(tg)
+end
+
+function matchDescendand(a,b)
+ return makeTag(a)..makeTag(b)
+end
+
+function matchChild(a,b)
+ return makeTag(a)..".*"..makeTag(b)
+end
+
+function matchSibling(a,b)
+ return makeTag(a .. "[^>]*".."@%("..b.."[^>]*%)")
+end
+
+function matchClass(tg,class)
+ return makeTag(tg.."[^>]*class=[|]*[^>]*|"..class.."[^>]*|")
+end
+matcher = {}
+function matcher.new()
+ local self = {}
+ local selectors={}
+ function self:addSelector(sel,val)
+ selectors[sel.."$"] = val
+ end
+ function self:testPath(path,fn)
+ for k, v in pairs(selectors) do
+ if path:match(k) then
+ fn(v)
+ end
+ end
+ end
+ return self
+end
+