summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-03-15 21:24:56 +0000
committerKarl Berry <karl@freefriends.org>2024-03-15 21:24:56 +0000
commit2f6bafae85663973e07b3d67b2c301b98502630a (patch)
tree8f4998344c3b83be661f068d3781dfa1ec7bcd74 /Master/texmf-dist/tex/luatex
parent1261bfda93af0c9eda08f6efbbf113d0031352df (diff)
penlightplus (15mar24)
git-svn-id: svn://tug.org/texlive/trunk@70656 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
-rw-r--r--Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua41
-rw-r--r--Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty28
2 files changed, 48 insertions, 21 deletions
diff --git a/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua b/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua
index a831c6721d8..e51b01c14bd 100644
--- a/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua
+++ b/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua
@@ -1,5 +1,5 @@
--% Kale Ewasiuk (kalekje@gmail.com)
---% 2024-02-29
+--% 2024-03-14
--% Copyright (C) 2021-2024 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -32,10 +32,15 @@ __PL_SKIP_TEX__ = __PL_SKIP_TEX__ or false --if declared true before here, it wi
__PL_GLOBALS__ = __PL_GLOBALS__ or false
__PL_NO_HYPERREF__ = __PL_NO_HYPERREF__ or false
-
penlight.luakeys = require'luakeys'()
-penlight.COMP = require'pl.comprehension'.new() -- for comprehensions
+penlight.debug_available = false -- check if penlight debug package is available
+if debug ~= nil then
+ if type(debug.getinfo) == 'function' then
+ penlight.debug_available = true
+ end
+end
+
-- http://lua-users.org/wiki/SplitJoin -- todo read me!!
@@ -719,17 +724,22 @@ function penlight.array2d.parse_numpy2d_str(s)
end
-local _parse_range = penlight.clone_function(penlight.array2d.parse_range)
-function penlight.array2d.parse_range(s) -- edit parse range to do numpy string if no letter passed
- penlight.utils.assert_arg(1,s,'string')
- if not s:find'%a' then
- return penlight.array2d.parse_numpy2d_str(s)
- end
- return _parse_range(s)
-end
+if not penlight.debug_available then
+ penlight.tex.pkgwarn('penlight', 'lua debug library is not available, recommend re-compiling with the --luadebug option')
+else
+ penlight.COMP = require'pl.comprehension'.new() -- for comprehensions
+ local _parse_range = penlight.clone_function(penlight.array2d.parse_range)
+ function penlight.array2d.parse_range(s) -- edit parse range to do numpy string if no letter passed
+ penlight.utils.assert_arg(1,s,'string')
+ if not s:find'%a' then
+ return penlight.array2d.parse_numpy2d_str(s)
+ end
+ return _parse_range(s)
+ end
+end
@@ -865,9 +875,11 @@ function penlight.get_tbl(s)
return penlight.tbls[s]
end
-function penlight.get_tbl_index(s)
+function penlight.get_tbl_index(s, undec)
+ undec = undec or false -- flag for allowing undeclared indexing
local tbl = ''
local key = ''
+ local s_raw = s
if s:find('%.') then
local tt = s:split('.')
tbl = tt[1]
@@ -884,8 +896,9 @@ function penlight.get_tbl_index(s)
if type(key) == 'number' and key < 0 then key = #penlight.tbls[tbl]+1+key end
end
if tbl == '' then tbl = penlight.rec_tbl end
- if penlight.tbls[tbl] == nil or penlight.tbls[tbl][key] == nil then
- penlight.tex.pkgerror('penlightplus', 'Invalid index of tbl using: "'..s..'"')
+
+ if (penlight.tbls[tbl] == nil) or ((not undec) and (penlight.tbls[tbl][key] == nil)) then
+ penlight.tex.pkgerror('penlightplus', 'Invalid tbl index attempt using: "'..s_raw..'". We tried to use tbl: "' ..tbl..'" and key: "'..key..'"')
end
return tbl, key
end
diff --git a/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty b/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty
index ee7ff3ad11f..3c411d227ac 100644
--- a/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty
+++ b/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2024-02-29
+% 2024-03-14
% Copyright (C) 2021-2024 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -22,7 +22,7 @@
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
% OR OTHER DEALINGS IN THE SOFTWARE.
-\ProvidesPackage{penlightplus}[2024-02-29]
+\ProvidesPackage{penlightplus}[2024-03-14]
\RequirePackage{luacode}
\RequirePackage{luakeys}
@@ -141,14 +141,14 @@
end
}}
-\NewDocumentCommand{\tbladd}{m m m}{\luadirect{% add a kv pair to a table
- __tbl__ = penlight.get_tbl_name(\luastring{#1})
- penlight.tbls[__tbl__][\luastring{#2}] = \luastring{#3}
+\NewDocumentCommand{\tbladd}{m m}{\luadirect{% add a kv pair to a table
+ __tbl__, __key__ = penlight.get_tbl_index(\luastring{#1}, true)
+ penlight.tbls[__tbl__][__key__] = \luastring{#2}
}}
\NewDocumentCommand{\tbladdN}{m m m}{\luadirect{% add a kv pair to a table
- __tbl__ = penlight.get_tbl_name(\luastring{#1})
- penlight.tbls[__tbl__][\luastring{#2}] = \luastringN{#3}
+ __tbl__, __key__ = penlight.get_tbl_index(\luastring{#1}, true)
+ penlight.tbls[__tbl__][__key__] = \luastringN{#2}
}}
@@ -183,8 +183,22 @@
\NewDocumentCommand{\tblprt}{m}{\luadirect{penlight.wrth(penlight.get_tbl(\luastring{#1}),'penlightplus table: '..\luastring{#1})}}
+
+
+
% legacy code, delete this
\let\kvtblundefcheck\tblkvundefcheck
+
+\NewDocumentCommand{\tbladdo}{m m m}{\luadirect{% add a kv pair to a table
+ __tbl__ = penlight.get_tbl_name(\luastring{#1})
+ penlight.tbls[__tbl__][\luastring{#2}] = \luastring{#3}
+}}
+
+\NewDocumentCommand{\tbladdNo}{m m m}{\luadirect{% add a kv pair to a table
+ __tbl__ = penlight.get_tbl_name(\luastring{#1})
+ penlight.tbls[__tbl__][\luastring{#2}] = \luastringN{#3}
+}}
+
\let\chgtbl\tblchg
\let\newtbl\tblnew
\let\gettbl\tblget