From d8e47184a9a1a04b1aa016bb4a56d066b8940805 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Tue, 22 Nov 2022 03:01:53 +0000 Subject: CTAN sync 202211220301 --- macros/luatex/generic/luakeys/luakeys-debug.sty | 2 +- macros/luatex/generic/luakeys/luakeys-doc.pdf | Bin 283942 -> 286697 bytes macros/luatex/generic/luakeys/luakeys-doc.tex | 79 +++++++++++++++--------- macros/luatex/generic/luakeys/luakeys.lua | 62 ++++++++++++------- macros/luatex/generic/luakeys/luakeys.sty | 2 +- 5 files changed, 93 insertions(+), 52 deletions(-) (limited to 'macros/luatex') diff --git a/macros/luatex/generic/luakeys/luakeys-debug.sty b/macros/luatex/generic/luakeys/luakeys-debug.sty index 5f8cc808f5..c7748db068 100644 --- a/macros/luatex/generic/luakeys/luakeys-debug.sty +++ b/macros/luatex/generic/luakeys/luakeys-debug.sty @@ -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 diff --git a/macros/luatex/generic/luakeys/luakeys-doc.pdf b/macros/luatex/generic/luakeys/luakeys-doc.pdf index 04e307a84d..e80b60f762 100644 Binary files a/macros/luatex/generic/luakeys/luakeys-doc.pdf and b/macros/luatex/generic/luakeys/luakeys-doc.pdf differ diff --git a/macros/luatex/generic/luakeys/luakeys-doc.tex b/macros/luatex/generic/luakeys/luakeys-doc.tex index f7d2940f66..ea427a3c5e 100644 --- a/macros/luatex/generic/luakeys/luakeys-doc.tex +++ b/macros/luatex/generic/luakeys/luakeys-doc.tex @@ -58,7 +58,7 @@ The default value of the option “\texttt{#1}” is: \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 @@ recursive data structure. % 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,13 +1161,22 @@ These data types can be searched for: 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 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 @@ For example, the string \lua{'true'} is recognized by the \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 @@ An example of how to use the command in \LaTeX: \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 @@ An example of how to use the command in \LaTeX: “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 diff --git a/macros/luatex/generic/luakeys/luakeys.lua b/macros/luatex/generic/luakeys/luakeys.lua index 8b065289de..a220413390 100644 --- a/macros/luatex/generic/luakeys/luakeys.lua +++ b/macros/luatex/generic/luakeys/luakeys.lua @@ -692,6 +692,10 @@ local is = { 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,33 +933,49 @@ local function apply_definitions(defs, 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 - end - if picked_value ~= nil then - input[i] = nil - return picked_value + + if picked_value ~= nil then + input[i] = nil + return picked_value + end end end end @@ -1230,7 +1250,7 @@ local result_store = {} -- @section local export = { - version = { 0, 8, 0 }, + version = { 0, 9, 0 }, namespace = namespace, diff --git a/macros/luatex/generic/luakeys/luakeys.sty b/macros/luatex/generic/luakeys/luakeys.sty index 68c3892ee4..459a9157ae 100644 --- a/macros/luatex/generic/luakeys/luakeys.sty +++ b/macros/luatex/generic/luakeys/luakeys.sty @@ -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')} -- cgit v1.2.3