summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/luatex/penlightplus/penlightplus.pdfbin78426 -> 79208 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex21
-rw-r--r--Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua31
-rw-r--r--Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty4
4 files changed, 45 insertions, 11 deletions
diff --git a/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.pdf b/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.pdf
index 4a5d6eece3d..545b9f5ec7f 100644
--- a/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.pdf
+++ b/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex b/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex
index 2b32dce4d85..7e8abe4027e 100644
--- a/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex
+++ b/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2025-01-01
+% 2025-01-05
% Copyright (C) 2021-2025 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -155,6 +155,7 @@ Some functionality is added to penlight and Lua.
\llcmd{string.}\cmd{containsanycase(s,t)} case-insensitive version\\
\llcmd{string.}\cmd{delspace(s)} clear spaces from string\\
\llcmd{string.}\cmd{subpar(s, c)} replaces \cmd{\\par} with a character of your choice default is space\\
+\llcmd{string.}\cmd{istexdim(s)} checks if a string is a valid tex dimension (eg. mm, pt, sp)\\
\llcmd{string.}\cmd{fmt(s, t, fmt)} format a string like \cmd{format_operator}, but with
a few improvements. \cmd{t} can be an array (reference items like \cmd{\$1} in the string),
and \cmd{fmt} can be a table of formats (keys correspond to those in \cmd{t}), or a string that
@@ -163,12 +164,12 @@ is processed by luakeys.\\
\llcmd{string.}\cmd{hasnoalpha(s)} string has no letters\\
\llcmd{string.}\cmd{hasnonum(s)} string has no numbers\\
\llcmd{string.}\cmd{isvarlike(s)} string is 'variable-like', starts with a letter or underscore and then is alphanumeric or has underscores after \\
-\begin{luacode*}
- pl.wrth(('_'):isvarlike(), 'llll')
- pl.wrth(('1_1k'):isvarlike(), ',,')
- pl.wrth(('kale_1'):isvarlike(), '')
- pl.wrth(('kale_1'):isvarlike(), '')
-\end{luacode*}
+%\begin{luacode*}
+% pl.wrth(('_'):isvarlike(), 'llll')
+% pl.wrth(('1_1k'):isvarlike(), ',,')
+% pl.wrth(('kale_1'):isvarlike(), '')
+% pl.wrth(('kale_1'):isvarlike(), '')
+%\end{luacode*}
\subsection*{tablex additions}
\llcmd{tablex.}\cmd{fmt(t, f)} format a table with table or key-value string f\\
@@ -178,6 +179,12 @@ is processed by luakeys.\\
\llcmd{tablex.}\cmd{mapslice(f,t,i1,i2)} map a function to elements between i1 and i2\\
\llcmd{tablex.}\cmd{listcontains(t,v)} checks if a value is in a array-style list \\
\llcmd{tablex.}\cmd{kkeys(t)} returns keys that are non-numeric (like kpairs) \\
+\llcmd{tablex.}\cmd{train(t,seq,reind)} return a sable based on \cmd{pl.seq.tbltrain}, \cmd{reind} will make numerical keys ordered from 1 \\
+
+%\begin{luacode*}
+% local t = {1,2,3,a='A',b='B'}
+% penlight.wrth(penlight.tablex.train(t,'2:3,*',true),'kew')
+%\end{luacode*}
\subsection*{List additions}
\llcmd{List:}\cmd{inject(l2, pos)} injects a list (l2) into a list at position. Set pos=0 to inject at end.
diff --git a/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua b/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua
index 53b023941d2..7eb80ab039d 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)
---% 2025-01-01
+--% 2025-01-05
--% Copyright (C) 2021-2025 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -196,7 +196,7 @@ end
if not penlight.debug_available then
- penlight.tex.pkgwarn('penlight', 'lua debug library is not available, recommend re-compiling with the --luadebug option')
+ penlight.tex.pkgwarn('penlightplus', 'lua debug library is not available, recommend re-compiling with the --luadebug option')
end
@@ -431,6 +431,7 @@ function str_mt.__index.gnum(s)
end
function str_mt.__index.gextract(s, pat) --extract a pattern from string, returns both
+ -- todo a variant where you can specify the number would be helpful
local s_extr = ''
local s_rem = s
for e in s:gmatch(pat) do
@@ -501,6 +502,17 @@ function str_mt.__index.trimfl(str)
return str:sub(2,-2)
end
+function str_mt.__index.istexdim(str)
+ for _, u in pairs{'pt', 'mm', 'cm', 'in', 'ex', 'em', 'mu', 'sp'} do
+ if penlight.hasval(str:delspace():find('^%-?%d*%.?%d+'..u..'$')) then
+ return true
+ end
+ end
+ return false
+end
+
+
+
function str_mt.__index.subpar(s, r)
r = r or ' '
return (s:gsub('\\par', r))
@@ -817,6 +829,21 @@ function penlight.tablex.filterstr(t, exp, case)
end
end
+
+function penlight.tablex.train(t,seq,reind)
+ local t_new = {}
+ local num = 0
+ for k, v in penlight.seq.tbltrain(t, seq) do
+ if reind and type(v) == 'number' then
+ num = num + 1
+ k = num
+ end
+ t_new[k] = v
+ end
+ return t_new
+end
+
+
--todo add doc
function penlight.utils.filterfiles(...)
-- f1 is a series of filtering patterns, or condition
diff --git a/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty b/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty
index 8b0a2634d10..ea4f01f4cf9 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)
-% 2025-01-01
+% 2025-01-05
% Copyright (C) 2021-2025 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}[2025-01-01]
+\ProvidesPackage{penlightplus}[2025-01-05]
\RequirePackage{luacode}
\RequirePackage{luakeys}