diff options
author | Karl Berry <karl@freefriends.org> | 2012-08-13 22:41:51 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-08-13 22:41:51 +0000 |
commit | 891d790aa1dafff5340c181e3dce3332526e4834 (patch) | |
tree | 049abb04059bc666a0ffa9c585547f5fee297a4c /Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua | |
parent | 99f6ebc940e504927ea38d6600f8ca9f893667bb (diff) |
new luatex package luaxml (13aug12)
git-svn-id: svn://tug.org/texlive/trunk@27394 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luaxml/luaxml-selectors.lua | 42 |
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 + |