texlive[73344] Master/texmf-dist: penlightplus (7jan25)

commits+karl at tug.org commits+karl at tug.org
Tue Jan 7 22:01:24 CET 2025


Revision: 73344
          https://tug.org/svn/texlive?view=revision&revision=73344
Author:   karl
Date:     2025-01-07 22:01:24 +0100 (Tue, 07 Jan 2025)
Log Message:
-----------
penlightplus (7jan25)

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-07 21:01:15 UTC (rev 73343)
+++ trunk/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex	2025-01-07 21:01:24 UTC (rev 73344)
@@ -1,5 +1,5 @@
 % Kale Ewasiuk (kalekje at gmail.com)
-% 2025-01-05
+% 2025-01-06
 % Copyright (C) 2021-2025 Kale Ewasiuk
 %
 % Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -50,7 +50,7 @@
 \addtokomafont{date}{\raggedright}
 \author{Kale Ewasiuk (\url{kalekje at gmail.com})}
 \usepackage[yyyymmdd]{datetime}\renewcommand{\dateseparator}{--}
-\date{\today}
+\date{\ \today}
 
 
 \RequirePackage[pl,globals]{penlightplus}
@@ -66,11 +66,15 @@
 
 \section*{Package Options and Set-Up}
 
-This package first loads the LaTeX \cmd{penlight[import]} package
-(\url{https://ctan.org/pkg/penlight?lang=en}).
-Documentation for the Lua package can be found here: \url{https://lunarmodules.github.io/Penlight/index.html}.\\
+This package first loads the LaTeX \cmd{penlight[import]} package:\\
+\url{https://ctan.org/pkg/penlight?lang=en}.\\
+Documentation for the Lua penlight package can be found here:\\ \url{https://lunarmodules.github.io/Penlight/index.html}.\\
 The \texttt{pl} option may be passed to this package to create an alias for \cmd{penlight}.\\
+A portion of this package to facilitate the creation, modification, and usage of the Lua table data structure
+through a LaTeX interface has been moved to a separate package called \cmd{luatbls}:\\
+\url{https://ctan.org/pkg/luatbls}.
 
+
 The following global Lua variables are defined:
 
 \cmd{__SKIP_TEX__} If using the \cmd{penlightplus} package with \cmd{texlua} (good for troubleshooting), set this global before loading \cmd{penlight}\\
@@ -84,8 +88,8 @@
 all \cmd{stringx} functions are injected into the \cmd{string} meta-table and you can use them like so: \cmd{'first name':upfirst()}.
 But if the package option \cmd{globals} is used, many additional globals are set for easier scripting.
 \cmd{pl.hasval},  \cmd{pl.COMP}, \cmd{pl.utils.kpairs}, \cmd{pl.utils.npairs} become globals.
-\cmd{pl.tablex} is aliased as \cmd{pl.tbx and tbx} (which also includes all native Lua table functions), and
-\cmd{pl.array2d} is aliased as \cmd{pl.a2d and a2d}.
+\cmd{pl.tablex} is aliased as \cmd{tbx} (which also includes all native Lua table functions), and
+\cmd{pl.array2d} is aliased as \cmd{a2d}.
 
 %If you want global \cmd{pl.tex} functions and variables, call \cmd{pl.make_tex_global()}.\\
 
@@ -118,13 +122,14 @@
 \llcmd{pl.hasval(x)} Python-like boolean testing\\
 \llcmd{COMP'xyz'()} Python-like comprehensions:\\\url{https://lunarmodules.github.io/Penlight/libraries/pl.comprehension.html}\\
 
-\llcmd{_Gdot(s)} Return a global (may contain dots) from string
+\llcmd{_Gdot(s)} return a global (may contain dots) from string
 
 \cmd{clone_function(f)} returns a cloned function\\
 \cmd{operator.strgt(a,b)} compares strings a greater than b  (useful for sorting)\\
 \cmd{operator.strlt(a,b)} compares strings a less than b (useful for sorting)\\
 
-\llcmd{math.mod(n,d)}, \cmd{math.mod2(n)} math modulous\\
+\llcmd{math.mod(n,d)} math modulus\\
+\cmd{math.mod2(n)} mod with base 2\\
 
 \llcmd{pl.utils.}\cmd{filterfiles}\cmd{(dir,filt,rec)} Get files from dir and apply glob-like filters. Set rec to \cmd{true} to include sub directories\\
 
@@ -148,7 +153,9 @@
 \llcmd{string.}\cmd{appif(s, append, bool, alternate)}\\
 \llcmd{string.}\cmd{gfirst(s, t)}return first matched patter from an array of patterns t\\
 %\llcmd{string.}\cmd{gnum(s)} extract a number from a string\\
-\llcmd{string.}\cmd{gextract(s)} extract a pattern from a string (returns capture and new string with capture removed)\\
+\llcmd{string.}\cmd{gextract(s,pat)} extract a pattern from a string (returns capture and new string with capture removed)\\
+\llcmd{string.}\cmd{gextrct(s,pat,num,join)} extract a pattern from a string (returns capture and new string with capture removed),
+can specify a number of extractions. if join is specified, captures will be joined, otherwise a list is returned\\
 \llcmd{string.}\cmd{totable(s)} string a table of characters\\
 \llcmd{string.}\cmd{tolist(s)} string a table of characters\\
 \llcmd{string.}\cmd{containsany(s,t)} checks if any of the array of strings \cmd{t} are in \cmd{s} using \cmd{string.find}\\
@@ -165,10 +172,12 @@
 \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(), '')
+%  local s1, s2 = ('12,13'):gxtrct('%d',nil)
+%  pl.wrth({s1,s2}, 'err rat')
+%--%  pl.wrth(('_'):isvarlike(), 'llll')
+%--%  pl.wrth(('1_1k'):isvarlike(), ',,')
+%--%  pl.wrth(('kale_1'):isvarlike(), '')
+%--%  pl.wrth(('kale_1'):isvarlike(), '')
 %\end{luacode*}
 
 \subsection*{tablex additions}
@@ -342,9 +351,6 @@
 %\caseswitch*{\mycase}{dog=DOG, cat=CAT, __=INVALID}
 
 
-\subsection*{Create, modify, and use Lua tables from within LaTeX}
-This portion of the package has been moved to a another package called
-\cmd{luatbls} \\(\url{https://ctan.org/pkg/luatbls})
 
 
 

Modified: trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua	2025-01-07 21:01:15 UTC (rev 73343)
+++ trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua	2025-01-07 21:01:24 UTC (rev 73344)
@@ -1,5 +1,5 @@
 --% Kale Ewasiuk (kalekje at gmail.com)
---% 2025-01-05
+--% 2025-01-06
 --% Copyright (C) 2021-2025 Kale Ewasiuk
 --%
 --% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -431,7 +431,6 @@
 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
@@ -441,6 +440,25 @@
     return s_extr, s_rem
 end
 
+function str_mt.__index.gxtrct(s, pat, num, join) --extract a pattern from string, returns both
+    -- todo a variant where you can specify the number of extractions, and either list of concatenate them would be helpful
+    local l_extr = penlight.List{}
+    local s_rem = s
+    local n = 1
+    num = num or 99999
+    for e in s:gmatch(pat) do
+        l_extr = l_extr:append(e)
+        s_rem = s_rem:gsub(e,'',1)
+        if n == num then break end
+        n = n +1
+    end
+    if join then
+        l_extr = l_extr:join(join)
+    end
+    return l_extr, s_rem
+end
+
+
 function str_mt.__index.gfirst(s, t) -- get the first pattern found from a table of pattern
     for _, pat in pairs(t) do
         if string.find(s, pat) then
@@ -844,6 +862,7 @@
 end
 
 
+
 --todo add doc
 function penlight.utils.filterfiles(...)
     -- f1 is a series of filtering patterns, or condition
@@ -981,7 +1000,7 @@
 
 
 if penlight.debug_available then
-     penlight.COMP = require'penlight.comprehension'.new() -- for comprehensions
+     penlight.COMP = penlight.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

Modified: trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty	2025-01-07 21:01:15 UTC (rev 73343)
+++ trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty	2025-01-07 21:01:24 UTC (rev 73344)
@@ -1,5 +1,5 @@
 % Kale Ewasiuk (kalekje at gmail.com)
-% 2025-01-05
+% 2025-01-06
 % 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-05]
+\ProvidesPackage{penlightplus}[2025-01-06]
 
 \RequirePackage{luacode}
 \RequirePackage{luakeys}



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