texlive[73335] Master/texmf-dist: penlightplus (6jan25)

commits+karl at tug.org commits+karl at tug.org
Mon Jan 6 22:20:09 CET 2025


Revision: 73335
          https://tug.org/svn/texlive?view=revision&revision=73335
Author:   karl
Date:     2025-01-06 22:20:09 +0100 (Mon, 06 Jan 2025)
Log Message:
-----------
penlightplus (6jan25)

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

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

Modified: trunk/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex	2025-01-06 21:19:57 UTC (rev 73334)
+++ trunk/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex	2025-01-06 21:20:09 UTC (rev 73335)
@@ -1,5 +1,5 @@
 % Kale Ewasiuk (kalekje at 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 @@
 \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 @@
 \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,7 +179,13 @@
 \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.
 \begin{luacode*}

Modified: trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua	2025-01-06 21:19:57 UTC (rev 73334)
+++ trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua	2025-01-06 21:20:09 UTC (rev 73335)
@@ -1,5 +1,5 @@
 --% Kale Ewasiuk (kalekje at 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 @@
 
 
 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 @@
 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 @@
     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 @@
     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

Modified: trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty	2025-01-06 21:19:57 UTC (rev 73334)
+++ trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty	2025-01-06 21:20:09 UTC (rev 73335)
@@ -1,5 +1,5 @@
 % Kale Ewasiuk (kalekje at 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}



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