diff options
author | Karl Berry <karl@freefriends.org> | 2020-12-20 21:33:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-12-20 21:33:59 +0000 |
commit | cafc1951d26f0c61d2140ea88b1225f4b419bdf0 (patch) | |
tree | e314a23d226e11b58598de62f2d19ed8db73225d /Master/texmf-dist/tex/luatex/luaxml/luaxml-parse-query.lua | |
parent | c2200f680c6ceead7e4304f793a36c24d1efa77e (diff) |
luaxml (20dec20)
git-svn-id: svn://tug.org/texlive/trunk@57183 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaxml/luaxml-parse-query.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luaxml/luaxml-parse-query.lua | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaxml/luaxml-parse-query.lua b/Master/texmf-dist/tex/luatex/luaxml/luaxml-parse-query.lua index 7931fa193fc..17ddeb82c55 100644 --- a/Master/texmf-dist/tex/luatex/luaxml/luaxml-parse-query.lua +++ b/Master/texmf-dist/tex/luatex/luaxml/luaxml-parse-query.lua @@ -12,11 +12,19 @@ do end local alphanum = R("az", "AZ", "09") local num = R("09") +local quotes = S("'\"") ^ 1 local white = S(" \t\n") ^ 0 --- this is a deviation from the upstream, we allow ":" in the tag name, because +-- this is a deviation from the upstream, we allow "|" in the tag name, because -- luaxml doesn't support XML namespaces and elements must be queried using --- dom:query_selector("namespace:element") +-- dom:query_selector("namespace|element") local word = (alphanum + S("_-") + S("|")) ^ 1 + +local combinators = S(">~+") + +local attr_name = (alphanum + S("_-")) ^ 1 +local attr_function = S("~|^$*") ^ 0 + +local attr_content = C((P(1) - quotes) ^ 1) local mark mark = function(name) return function(...) @@ -34,8 +42,13 @@ parse_query = function(query) local any = P("*") / mark("any") local nth = P(":nth-child(") * C(num ^ 1) * ")" / mark("nth-child") local first = P(":first-child") / mark("first-child") + local first_of_type = P(":first-of-type") / mark("first-of-type") + local last = P(":last-child") / mark("last-child") + local last_of_type = P(":last-of-type") / mark("last-of-type") local attr = P("[") * C(word) * P("]") / mark("attr") - local selector = Ct((any + nth + first + tag + cls + id + attr) ^ 1) + local attr_value = P("[") * C(attr_name ) * C(attr_function)* P("=") * quotes * attr_content * quotes * P("]") / mark("attr_value") + local combinator = C(combinators) / mark("combinator") + local selector = Ct((any + nth + first + first_of_type + last + last_of_type + tag + cls + id + attr + attr_value + combinator) ^ 1) local pq = Ct(selector * (white * selector) ^ 0) local pqs = Ct(pq * (white * P(",") * white * pq) ^ 0) pqs = pqs * (white * -1) |