summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2025-01-11 20:50:36 +0000
committerKarl Berry <karl@freefriends.org>2025-01-11 20:50:36 +0000
commit3885953d9714de73fa416a736d408f91b06d534d (patch)
tree097128e7ab50bccb9e9752bd8bb49673ac92ee78
parent41c1422f8fb09313a4328a428aeb1202d3771ec0 (diff)
penlightplus (11jan25)
git-svn-id: svn://tug.org/texlive/trunk@73425 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/luatex/penlightplus/penlightplus.pdfbin78659 -> 78921 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex22
-rw-r--r--Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua53
-rw-r--r--Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty4
4 files changed, 74 insertions, 5 deletions
diff --git a/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.pdf b/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.pdf
index 4b7dfa5b504..6390e6f9866 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 c7f5c31129d..e639aad0ebc 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-06
+% 2025-01-11
% Copyright (C) 2021-2025 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -133,6 +133,10 @@ Some functionality is added to penlight and Lua.
\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 @@ is processed by luakeys.\\
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
diff --git a/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua b/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua
index 4d2f607ed7e..7b5beaf6058 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-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,21 @@ end
+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
+
@@ -863,6 +878,40 @@ end
+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
diff --git a/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty b/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty
index 94b2307dc0d..aca4cb26ab5 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-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}