texlive[60709] Master/texmf-dist: luaxml (7oct21)

commits+karl at tug.org commits+karl at tug.org
Thu Oct 7 22:33:37 CEST 2021


Revision: 60709
          http://tug.org/svn/texlive?view=revision&revision=60709
Author:   karl
Date:     2021-10-07 22:33:37 +0200 (Thu, 07 Oct 2021)
Log Message:
-----------
luaxml (7oct21)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/luatex/luaxml/README
    trunk/Master/texmf-dist/doc/luatex/luaxml/luaxml.pdf
    trunk/Master/texmf-dist/doc/luatex/luaxml/luaxml.tex
    trunk/Master/texmf-dist/tex/luatex/luaxml/luaxml-cssquery.lua
    trunk/Master/texmf-dist/tex/luatex/luaxml/luaxml-transform.lua

Modified: trunk/Master/texmf-dist/doc/luatex/luaxml/README
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luaxml/README	2021-10-07 20:33:22 UTC (rev 60708)
+++ trunk/Master/texmf-dist/doc/luatex/luaxml/README	2021-10-07 20:33:37 UTC (rev 60709)
@@ -28,7 +28,7 @@
 ------
 Michal Hoftich
 Email: michal.h21 at gmail.com
-Version: v0.1p, 2021-09-10
+Version: v0.1q, 2021-10-06
 
 Original authors: Paul Chakravarti and Manoel Campos (http://manoelcampos.com)
 

Modified: trunk/Master/texmf-dist/doc/luatex/luaxml/luaxml.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/luatex/luaxml/luaxml.tex
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luaxml/luaxml.tex	2021-10-07 20:33:22 UTC (rev 60708)
+++ trunk/Master/texmf-dist/doc/luatex/luaxml/luaxml.tex	2021-10-07 20:33:37 UTC (rev 60709)
@@ -7,7 +7,7 @@
 \usepackage{framed}
 % Version is defined in the makefile, use default values when compiled directly
 \ifdefined\version\else
-\def\version{v0.1p}
+\def\version{v0.1q}
 \let\gitdate\date
 \fi
 \newcommand\modulename[1]{\subsection{#1}\label{sec:#1}}

Modified: trunk/Master/texmf-dist/tex/luatex/luaxml/luaxml-cssquery.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luaxml/luaxml-cssquery.lua	2021-10-07 20:33:22 UTC (rev 60708)
+++ trunk/Master/texmf-dist/tex/luatex/luaxml/luaxml-cssquery.lua	2021-10-07 20:33:37 UTC (rev 60709)
@@ -41,11 +41,15 @@
     local query = query or {}
     local specificity = 0
     for _, item in ipairs(query.query or {}) do
-      for key, value in pairs(item) do
+      for _, t in ipairs(item) do
+        local key = t.key
+      -- for key, value in pairs(item) do
         if key == "id" then
           specificity = specificity + 100
         elseif key == "tag" then
           specificity = specificity + 1
+        elseif key == "any" then
+          -- * has 0 specificity
         else
           specificity = specificity + 10
         end
@@ -215,7 +219,7 @@
         -- ignore combinators in this function
       else
         if type(value) == "table" then value = table.concat(value, ":") end
-        print("unsupported feature", key, value)
+        self:debug_print("unsupported feature", key, value)
         return false
       end
       -- TODO: Add more cases
@@ -226,7 +230,9 @@
     local function test_object(query, el)
       -- test one object in CSS selector
       local matched = {}
-      for key, value in pairs(query) do
+      -- for key, value in pairs(query) do
+      for _, part in ipairs(query) do
+        local key, value = part.key, part.value
         local test =  test_part(key, value, el)
         if test~= true then return false end
         matched[#matched+1] = test
@@ -252,9 +258,10 @@
       local selector = query[#query] -- get the last item in selector query
       if not selector then return nil end
       -- detect if this selector is a combinator"
-      if selector and selector.combinator  then
+      -- combinator  object must have only one part, so we can assume that it is in the first part
+      if selector and selector[1].key == "combinator"  then
         -- save the combinator and select next selector from the query  
-        combinator = selector.combinator
+        combinator = selector[1].value
         table.remove(query) -- remove combinator from query
       end
       return combinator
@@ -271,7 +278,7 @@
 
     local function match_query(query, el)
       local function match_parent(query, el)
-        -- loop over the whole elemnt three and try to mach the css selector
+        -- loop over the whole element tree and try to mach the css selector
         if el and el:is_element() then
           local query = query or {}
           local object = query[#query]
@@ -354,6 +361,7 @@
       for _, part in ipairs(item) do
         local t = {}
         for _, atom in ipairs(part) do
+          
           local key = atom[1]
           local value
           if not atom[3] then
@@ -370,7 +378,7 @@
             -- to match namespace:element
             value=value:gsub("|", ":")
           end
-          t[key] =  value
+          t[#t+1] = {key=key,  value=value}
         end
         query[#query + 1] = t
       end

Modified: trunk/Master/texmf-dist/tex/luatex/luaxml/luaxml-transform.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luaxml/luaxml-transform.lua	2021-10-07 20:33:22 UTC (rev 60708)
+++ trunk/Master/texmf-dist/tex/luatex/luaxml/luaxml-transform.lua	2021-10-07 20:33:37 UTC (rev 60709)
@@ -30,6 +30,13 @@
   local selectors = css:match_querylist(element)
   if #selectors == 0 then return nil end
   -- return function with the highest specificity
+  local last_specificity = selectors[1].specificity
+  -- if multiple selectors have the same specificity, return the last one
+  for i, x in ipairs(selectors) do
+    if x.specificity < last_specificity then
+      return selectors[i-1].func
+    end
+  end
   return selectors[1].func
 end
 
@@ -135,7 +142,7 @@
       elseif name:match("^[0-9]+$") then
         local child = get_child_element(element, tonumber(name))
         if child then
-          return process_children(child, parameters)
+          return process_tree(child)
         end
       -- @<CSS selector> returns contents of matched selectors
       else



More information about the tex-live-commits mailing list.