texlive[73425] Master/texmf-dist: penlightplus (11jan25)
commits+karl at tug.org
commits+karl at tug.org
Sat Jan 11 21:50:36 CET 2025
Revision: 73425
https://tug.org/svn/texlive?view=revision&revision=73425
Author: karl
Date: 2025-01-11 21:50:36 +0100 (Sat, 11 Jan 2025)
Log Message:
-----------
penlightplus (11jan25)
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-11 20:50:19 UTC (rev 73424)
+++ trunk/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex 2025-01-11 20:50:36 UTC (rev 73425)
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje at gmail.com)
-% 2025-01-06
+% 2025-01-11
% Copyright (C) 2021-2025 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -133,7 +133,11 @@
\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\\
+\llcmd{pl.}{trysplitcomma(s)} will try to split a string on comma (and strip), but if is a table, leave it
+\llcmd{pl.}\cmd{findfiles{}} or \cmd{findfiles'kv'} is an updated version of \cmd{filterfiles}. Pass a table or a luakeys
+kv string as the only argument. Valid table options are: \cmd{fn, dir, ext, sub}.
+
\llcmd{pl.}\cmd{char(n)} return letter corresponding to 1=a, 2=b, etc.\\
\llcmd{pl.}\cmd{Char(n)} return letter corresponding to 1=A, 2=B, etc.\\
@@ -202,9 +206,25 @@
pl.wrth(l:inject({'a','b','c'},0), 'INJECTED')
\end{luacode*}
+\begin{luacode*}
+ f = pl.findfiles'fn=pen*, ext=".lua, .sty, .pdf", sub=false'
+ pl.wrth(f, 'FILES')
+ --penlight.wrth(penlight.dir.getallfiles('.', '*pen*'), 'ALLFILES')
+ pl.wrth(pl.file.access_time('penlightplus'), 'ACCESS TIME')
+ pl.wrth(pl.file.access_time('penlightpluxs'), 'ACCESS TIME')
+ if xdasdsa == nil then
+ penlight.utils.on_error('error')
+ --texio.write_nl('LaTeX Warning: FK )')
+ -- return penlight.utils.raise('Invalid path was attempted')
+ -- penlight.utils.on_error('stop')
+ -- return penlight.utils.raise('...')
+ end
+\end{luacode*}
+
\subsubsection*{seq additions}
A syntax to produce sequences or a 'train' of numbers is provided. This may be useful for including pages from a pdf, or selecting rows of a table with a concise syntax.\\
+\llcmd{seq.}\cmd{prod(t1, t2)} iterate over the cartesian product of t1 and t2\\
\llcmd{seq.}\cmd{train(trn, len)} produces a pl.List according to the arguments\\
\llcmd{seq.}\cmd{itrain(trn, len)} produces an iterator according to the arguments.\\
\llcmd{seq.}\cmd{tbltrain(tbl, trn)} produces an iterator over a table
Modified: trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua 2025-01-11 20:50:19 UTC (rev 73424)
+++ trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua 2025-01-11 20:50:36 UTC (rev 73425)
@@ -1,5 +1,5 @@
--% Kale Ewasiuk (kalekje at gmail.com)
---% 2025-01-06
+--% 2025-01-11
--% Copyright (C) 2021-2025 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -7,7 +7,7 @@
--% in the Software without restriction, including without limitation the rights
--% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
--% copies of the Software, and to permit persons to whom the Software is
---% furnished to do so, subjdeect to the following conditions:
+--% furnished to do so, subjected to the following conditions:
--%
--% The above copyright notice and this permission notice shall be included in
--% all copies or substantial portions of the Software.
@@ -712,6 +712,20 @@
+function penlight.seq.prod(t1, t2)
+ -- cartesian prduct of two tables (uses ipairs)
+ local t_new = {}
+ for _, v1 in ipairs(t1) do
+ for _, v2 in ipairs(t2) do
+ t_new[#t_new + 1] = {v1, v2}
+ end
+ end
+ local i = 0
+ return function ()
+ i = i + 1
+ if i <= #t_new then return t_new[i][1], t_new[i][2] end
+ end
+end
@@ -718,6 +732,7 @@
+
-- -- -- -- -- -- -- -- -- -- -- -- functions below extend the operator module
function penlight.operator.strgt(a,b) return tostring(a) > tostring(b) end
@@ -863,6 +878,40 @@
+function penlight.trysplitcomma(s)
+ strip = strip or false
+ if type(s) == 'number' then s = tostring(s) end
+ if type(s) == 'string' then
+ return s:splitstrip(',')
+ end
+ return s
+end
+
+
+function penlight.findfiles(kv)
+ if type(kv) == 'string' then kv = penlight.luakeys.parse(kv) end
+ kv = penlight.tablex.update({dir={'.'}, fn={'*'}, ext={''}, sub=false}, kv)
+ kv.dir = penlight.trysplitcomma(kv.dir)
+ kv.fn = penlight.trysplitcomma(kv.fn)
+ kv.ext = penlight.trysplitcomma(kv.ext)
+ --local files_all = penlight.getallfilesdirs(kv.dir, kv.sub)
+ local getfiles = penlight.dir.getfiles
+ if penlight.hasval(kv.sub) then
+ getfiles = function(dir, fn) return penlight.dir.getallfiles(dir, '*'..fn) end -- need * in front so folder does not affect result
+ end
+ local files = penlight.List{}
+ for fn, ext in penlight.seq.prod(kv.fn, kv.ext) do
+ for _, dir in ipairs(kv.dir) do
+ penlight.wrth(dir..fn..ext)
+ files:extend(getfiles(dir, fn..ext))
+ end
+ end
+ files = pl.List(penlight.tablex.keys(pl.Set(files))) -- clear duplicates
+ files = files:map(function(s) return s:gsub('\\','/') end) -- change slash for latex
+ return files
+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-11 20:50:19 UTC (rev 73424)
+++ trunk/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty 2025-01-11 20:50:36 UTC (rev 73425)
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje at gmail.com)
-% 2025-01-06
+% 2025-01-11
% 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-06]
+\ProvidesPackage{penlightplus}[2025-01-11]
\RequirePackage{luacode}
\RequirePackage{luakeys}
More information about the tex-live-commits
mailing list.