texlive[65071] Master/texmf-dist: luakeys (21nov22)

commits+karl at tug.org commits+karl at tug.org
Mon Nov 21 21:51:02 CET 2022


Revision: 65071
          http://tug.org/svn/texlive?view=revision&revision=65071
Author:   karl
Date:     2022-11-21 21:51:01 +0100 (Mon, 21 Nov 2022)
Log Message:
-----------
luakeys (21nov22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/luatex/luakeys/luakeys-doc.pdf
    trunk/Master/texmf-dist/doc/luatex/luakeys/luakeys-doc.tex
    trunk/Master/texmf-dist/tex/luatex/luakeys/luakeys-debug.sty
    trunk/Master/texmf-dist/tex/luatex/luakeys/luakeys.lua
    trunk/Master/texmf-dist/tex/luatex/luakeys/luakeys.sty

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

Modified: trunk/Master/texmf-dist/doc/luatex/luakeys/luakeys-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/luakeys/luakeys-doc.tex	2022-11-21 20:50:48 UTC (rev 65070)
+++ trunk/Master/texmf-dist/doc/luatex/luakeys/luakeys-doc.tex	2022-11-21 20:51:01 UTC (rev 65071)
@@ -58,7 +58,7 @@
   \href{https://github.com/Josef-Friedrich/luakeys}
        {github.com/Josef-Friedrich/luakeys}%
 }
-\date{0.8.0 from 2022/11/17}
+\date{0.9.0 from 2022/11/21}
 
 \maketitle
 
@@ -1151,12 +1151,9 @@
 % Die Suche nach Werte wird aktiviert, wenn das Attribut \lua{pick} auf
 % \lua{true} gesetzt wird.
 The search for values is activated when the attribute \lua{pick} is set
-to \lua{true}.
-% Die Suche kann eingeschränkt werden, indem ein Datentype angegeben
-% wird.
-The search can be limited by specifying a data type.
-% Nach diesen Datentypen kann gesucht werden:
-These data types can be searched for:
+to a data type.
+% Mit diesen Datentypen kann nach Werten gesucht werden
+These data types can be used to search for values:
 \directlua{
   local types = {}
   for t, fn in pairs(luakeys.is) do
@@ -1164,7 +1161,8 @@
   end
   tex.print(table.concat(types, ', '))
 }.
-
+% Verwendet den Datentyp any um jeden beliebigen Wert zu akzeptieren.
+Use the data type “any” to accept any value.
 % Wird einem Schlüssel bereits bei der Eingabe ein Wert zugewiesen, dann
 % wird nicht weiter nach Werten gesucht.
 If a value is already assigned to a key when it is entered, then no
@@ -1171,6 +1169,14 @@
 further search for values is performed.
 \InputLua[firstline=4,lastline=8]{defs/attrs/pick/value-set.lua}
 
+\noindent
+% Das Attribut \lua{pick} akzeptiert auch mehrere Datentypen, die in
+% einer Tabelle angegeben werden.
+The \lua{pick} attribute also accepts multiple data types
+specified in a table.
+
+\InputLua[firstline=4,lastline=10]{defs/attrs/pick/multiple-data-types.lua}
+
 %%
 %
 %%
@@ -1383,6 +1389,13 @@
 \subsubsection{Function “\texttt{is.string(value): boolean}”}
 \InputLua[firstline=6,lastline=12]{functions/is/string.lua}
 
+\subsubsection{Function “\texttt{is.any(value): boolean}”}
+
+% Die Funktion \lua{is.any(value)}  gibt immer wahr zurück und
+% akzeptiert deshalb jeden Datentyp.
+The function \lua{is.any(value)} always returns \lua{true} and
+therefore accepts any data type.
+
 %%
 %
 %%
@@ -1886,47 +1899,47 @@
 
 \changes{0.1.0}{2021/01/18}{Inital release}
 \changes{0.2.0}{2021/09/19}{
-* Allow all recognized data types as keys
-* Allow TeX macros in the values
-* New public Lua functions: save(identifier, result), get(identifier)
+* Allow all recognized data types as keys.
+* Allow TeX macros in the values.
+* New public Lua functions: save(identifier, result), get(identifier).
 }
 \changes{0.3.0}{2021/11/05}{
-* Add a LuaLaTeX wrapper “luakeys.sty”
-* Add a plain LuaTeX wrapper “luakeys.tex”
-* Rename the previous documentation file “luakeys.tex” to luakeys-doc.tex”
+* Add a LuaLaTeX wrapper “luakeys.sty”.
+* Add a plain LuaTeX wrapper “luakeys.tex”.
+* Rename the previous documentation file “luakeys.tex” to luakeys-doc.tex”.
 }
 \changes{0.4.0}{2021/12/31}{
-* Parser: Add support for nested tables (for example {{'a', 'b'}})
-* Parser: Allow only strings and numbers as keys
-* Parser: Remove support from Lua numbers with exponents (for example '5e+20')
-* Switch the Lua testing framework to busted
+* Parser: Add support for nested tables (for example {{'a', 'b'}}).
+* Parser: Allow only strings and numbers as keys.
+* Parser: Remove support from Lua numbers with exponents (for example '5e+20').
+* Switch the Lua testing framework to busted.
 }
 \changes{0.5.0}{2022/04/04}{
-* Add possibility to change options globally
-* New option: standalone_as_true
-* Add a recursive converter callback / hook to process the parse tree
-* New option: case_insensitive_keys
+* Add possibility to change options globally.
+* New option: standalone_as_true.
+* Add a recursive converter callback / hook to process the parse tree.
+* New option: case_insensitive_keys.
 }
 \changes{0.6.0}{2022/06/09}{
 * New feature: keys now can be defined using the function
   “define(defs, opts)” or “define(kv_string, { defs = { key = { ... } } })”
-* Rename the global options table from “default_options” to “opts”
-* New option “format_keys”
+* Rename the global options table from “default_options” to “opts”.
+* New option “format_keys”.
 * Remove option “case_insensitive_keys”. Use
   “format_keys = \{ lower \}” to achieve the same effect.
 * The default value of the option “convert_dimension” is now false.
 * The option “standalone_as_true” is renamed to “naked_as_value”.
-  The boolean value of the option must be changed to the opposite to
+  The boolean value of the option must be changed to the opposite to.
   produce the previous effect.
-* The function “print()” is now called “debug()”
+* The function “print()” is now called “debug()”.
 }
 \changes{0.7.0}{2022/07/06}{
 * The project now uses semantic versioning.
 * New definition attribute “pick” to pick standalone values and assign
-  them to a key
+  them to a key.
 * New function “utils.scan_oarg()” to search for an optional argument,
-  that means scan for tokens that are enclosed in square brackets
-* extend and improve documentation
+  that means scan for tokens that are enclosed in square brackets.
+* Extend and improve the documentation.
 }
 \changes{0.8.0}{2022/11/17}{
 * Add 6 new options to change the delimiters: “assignment_operator”,
@@ -1934,6 +1947,14 @@
   “quotation_end”.
 * Extend the documentation about the option “format_keys”.
 }
+\changes{0.9.0}{2022/11/21}{
+* The definition attibute “pick” accepts a new data type: “any”.
+* The attribute value “true” for the attribute “pick” is deprecated.
+* The attribute “pick” accepts now multiple data types specified in
+  a table.
+* Add a new function called “any(value)” in the “is” table that accepts
+  any data type.
+}
 \pagebreak
 \PrintChanges
 \pagebreak

Modified: trunk/Master/texmf-dist/tex/luatex/luakeys/luakeys-debug.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luakeys/luakeys-debug.sty	2022-11-21 20:50:48 UTC (rev 65070)
+++ trunk/Master/texmf-dist/tex/luatex/luakeys/luakeys-debug.sty	2022-11-21 20:51:01 UTC (rev 65071)
@@ -17,6 +17,6 @@
 % luakeys-debug.sty and luakeys-debug.tex.
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{luakeys-debug}[2022/11/17 0.8.0 Debug package for luakeys.]
+\ProvidesPackage{luakeys-debug}[2022/11/21 0.9.0 Debug package for luakeys.]
 
 \input luakeys-debug.tex

Modified: trunk/Master/texmf-dist/tex/luatex/luakeys/luakeys.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luakeys/luakeys.lua	2022-11-21 20:50:48 UTC (rev 65070)
+++ trunk/Master/texmf-dist/tex/luatex/luakeys/luakeys.lua	2022-11-21 20:51:01 UTC (rev 65071)
@@ -692,6 +692,10 @@
   string = function(value)
     return type(value) == 'string'
   end,
+
+  any = function(value)
+    return true
+  end,
 }
 
 --- Apply the key-value-pair definitions (defs) on an input table in a
@@ -929,34 +933,50 @@
 
     pick = function(value, key, def)
       if def.pick then
-        if type(def.pick) == 'string' and is[def.pick] == nil then
-          throw_error(
-            'Wrong setting. Allowed settings for the attribute “def.pick” are: true, boolean, dimension, integer, number, string. Got “' ..
-              tostring(def.pick) .. '”.')
+        local pick_types
+
+        -- Allow old deprecated attribut pick = true
+        if def.pick == true then
+          pick_types = { 'any' }
+        elseif type(def.pick) == 'table' then
+          pick_types = def.pick
+        else
+          pick_types = { def.pick }
         end
 
+        -- Check if the pick attribute is valid
+        for _, pick_type in ipairs(pick_types) do
+          if type(pick_type) == 'string' and is[pick_type] == nil then
+            throw_error(
+              'Wrong data type in the “pick” attribute: ' ..
+                tostring(pick_type) ..
+                '. Allowed are: any, boolean, dimension, integer, number, string.')
+          end
+        end
+
+        -- The key has already a value. We leave the function at this
+        -- point to be able to check the pick attribute for errors
+        -- beforehand.
         if value ~= nil then
           return value
         end
-        for i, v in pairs(input) do
-          -- We can not use ipairs here. `ipairs(t)` iterates up to the
-          -- first absent index. Values are deleted from the `input`
-          -- table.
-          if type(i) == 'number' then
-            local picked_value = nil
-            -- Pick a value by type:  boolean, dimension, integer, number, string
-            if is[def.pick] ~= nil then
-              if is[def.pick](v) then
+
+        for _, pick_type in ipairs(pick_types) do
+          for i, v in pairs(input) do
+            -- We can not use ipairs here. `ipairs(t)` iterates up to the
+            -- first absent index. Values are deleted from the `input`
+            -- table.
+            if type(i) == 'number' then
+              local picked_value = nil
+              if is[pick_type](v) then
                 picked_value = v
               end
-              -- Pick every value
-            elseif v ~= nil then
-              picked_value = v
+
+              if picked_value ~= nil then
+                input[i] = nil
+                return picked_value
+              end
             end
-            if picked_value ~= nil then
-              input[i] = nil
-              return picked_value
-            end
           end
         end
       end
@@ -1230,7 +1250,7 @@
 -- @section
 
 local export = {
-  version = { 0, 8, 0 },
+  version = { 0, 9, 0 },
 
   namespace = namespace,
 

Modified: trunk/Master/texmf-dist/tex/luatex/luakeys/luakeys.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/luakeys/luakeys.sty	2022-11-21 20:50:48 UTC (rev 65070)
+++ trunk/Master/texmf-dist/tex/luatex/luakeys/luakeys.sty	2022-11-21 20:51:01 UTC (rev 65071)
@@ -17,5 +17,5 @@
 % luakeys-debug.sty and luakeys-debug.tex.
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{luakeys}[2022/11/17 0.8.0 Parsing key-value options using Lua.]
+\ProvidesPackage{luakeys}[2022/11/21 0.9.0 Parsing key-value options using Lua.]
 \directlua{luakeys = require('luakeys')}



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