diff options
author | Karl Berry <karl@freefriends.org> | 2022-11-21 20:51:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-11-21 20:51:01 +0000 |
commit | 5ec2801a90c0497799b7ea7f02a76da3b444cc67 (patch) | |
tree | 9ba85dd745cac5711240e1bb92ce1c1bdc62254b /Master/texmf-dist/tex | |
parent | 50fb90792b5ec87def8bcb5506575df7ed1b1c0d (diff) |
luakeys (21nov22)
git-svn-id: svn://tug.org/texlive/trunk@65071 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luakeys/luakeys-debug.sty | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luakeys/luakeys.lua | 62 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luakeys/luakeys.sty | 2 |
3 files changed, 43 insertions, 23 deletions
diff --git a/Master/texmf-dist/tex/luatex/luakeys/luakeys-debug.sty b/Master/texmf-dist/tex/luatex/luakeys/luakeys-debug.sty index 5f8cc808f52..c7748db068f 100644 --- a/Master/texmf-dist/tex/luatex/luakeys/luakeys-debug.sty +++ b/Master/texmf-dist/tex/luatex/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/Master/texmf-dist/tex/luatex/luakeys/luakeys.lua b/Master/texmf-dist/tex/luatex/luakeys/luakeys.lua index 8b065289de8..a2204133906 100644 --- a/Master/texmf-dist/tex/luatex/luakeys/luakeys.lua +++ b/Master/texmf-dist/tex/luatex/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/Master/texmf-dist/tex/luatex/luakeys/luakeys.sty b/Master/texmf-dist/tex/luatex/luakeys/luakeys.sty index 68c3892ee43..459a9157aec 100644 --- a/Master/texmf-dist/tex/luatex/luakeys/luakeys.sty +++ b/Master/texmf-dist/tex/luatex/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')} |