diff options
author | Karl Berry <karl@freefriends.org> | 2025-01-07 21:01:24 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2025-01-07 21:01:24 +0000 |
commit | 873fc1dea332b3f536c24a5543946960ad5604a5 (patch) | |
tree | 7971aad35f9cba5ba1b64d3ab6a4a75ec3108b70 /Master/texmf-dist | |
parent | 89cf948eef029a951f16eeb24d3dbc1ad167a242 (diff) |
penlightplus (7jan25)
git-svn-id: svn://tug.org/texlive/trunk@73344 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/luatex/penlightplus/penlightplus.pdf | bin | 79208 -> 78659 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex | 40 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua | 25 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty | 4 |
4 files changed, 47 insertions, 22 deletions
diff --git a/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.pdf b/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.pdf Binary files differindex 545b9f5ec7f..4b7dfa5b504 100644 --- a/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.pdf +++ b/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.pdf diff --git a/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex b/Master/texmf-dist/doc/luatex/penlightplus/penlightplus.tex index 7e8abe4027e..c7f5c31129d 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-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@gmail.com})} \usepackage[yyyymmdd]{datetime}\renewcommand{\dateseparator}{--} -\date{\today} +\date{\ \today} \RequirePackage[pl,globals]{penlightplus} @@ -66,10 +66,14 @@ \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: @@ -84,8 +88,8 @@ Since this package uses the penlight \cmd{import} option, 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 @@ Some functionality is added to penlight and Lua. \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 @@ Some functionality is added to penlight and Lua. \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 @@ is processed by luakeys.\\ \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 @@ Use \_\_ as a placeholder for a case that isn't matched. The case is fully expan %\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}) diff --git a/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua b/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.lua index 7eb80ab039d..4d2f607ed7e 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-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 @@ 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 @@ -441,6 +440,25 @@ function str_mt.__index.gextract(s, pat) --extract a pattern from string, return 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 @@ function penlight.tablex.train(t,seq,reind) end + --todo add doc function penlight.utils.filterfiles(...) -- f1 is a series of filtering patterns, or condition @@ -981,7 +1000,7 @@ end 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 diff --git a/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty b/Master/texmf-dist/tex/luatex/penlightplus/penlightplus.sty index ea4f01f4cf9..94b2307dc0d 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-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} |