texlive[67672] Master/texmf-dist: penlight (19jul23)

commits+karl at tug.org commits+karl at tug.org
Wed Jul 19 22:48:38 CEST 2023


Revision: 67672
          http://tug.org/svn/texlive?view=revision&revision=67672
Author:   karl
Date:     2023-07-19 22:48:38 +0200 (Wed, 19 Jul 2023)
Log Message:
-----------
penlight (19jul23)

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

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

Modified: trunk/Master/texmf-dist/doc/luatex/penlight/penlight.tex
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/penlight/penlight.tex	2023-07-19 20:48:30 UTC (rev 67671)
+++ trunk/Master/texmf-dist/doc/luatex/penlight/penlight.tex	2023-07-19 20:48:38 UTC (rev 67672)
@@ -1,5 +1,5 @@
 % Kale Ewasiuk (kalekje at gmail.com)
-% 2022-10-24
+% 2023-07-18
 % Copyright (C) 2021-2022 Kale Ewasiuk
 %
 % Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -58,7 +58,6 @@
 \subtitle{Lua libraries for use in LuaLaTeX}
 
 \begin{document}
-
 %{\Huge todo add split to text example with ltxexample\\reference the exact version of penlight used in this library. consider no globals by default\\ COVERT existing examples to extras globals, document hyperref}
 
 \maketitle
@@ -113,11 +112,10 @@
 
 
 \subsection*{Extras}
+Note: this option is considered experimental.
+The following global variables are defined:
 
-If \cmd{extras} is used, the following Lua globals will be defined:\\
-
-\subsubsection*{Misc stuff}
-\llcmd{__SKIP_TEX__} If using package with \cmd{texlua}, set this global before loading \cmd{penlight}\\
+\llcmd{__SKIP_TEX__} If using the \cmd{penlight} package with \cmd{texlua} (good for troubleshooting), set this global before loading \cmd{penlight}\\
 The gloals flags below are taken care of in the package options:\\
 \llcmd{__PL_}\cmd{GLOBALS__} If using package with \cmd{texlua} and you don't want to set some globals (described in next sections), set this global before to \cmd{true} loading \cmd{penlight}\\
 \cmd{__SKIP_LUAKEYS__}\\
@@ -124,7 +122,11 @@
 \cmd{__PL_NO_HYPERREF__}\\
 \cmd{__PL_EXTRAS__} false, 1 or 2\\
 
-\llcmd{hasval(x)} Python-like boolean testing\\
+\subsubsection*{penlight additions}
+
+Some functionality is added to penlight/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{math.mod(n,d)}, \cmd{math.mod2(n)} math modulous\\
 \llcmd{string.}\cmd{totable(s)} string a table of characters\\
@@ -131,15 +133,11 @@
 \llcmd{string.}\cmd{delspace(s)} clear spaces from string\\
 \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.\\
-\llcmd{kpairs(t), }\cmd{npairs(t)} iterate over keys only, or include nil value from table ipairs\\
 
-
-%{\Large todo document all string helper functions}
-
 \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\\
 
 
-\subsubsection*{\cmd{pl.tex.} module is added}
+\subsubsection*{A \cmd{pl.tex.} module is added}
 \llcmd{add_bkt}\cmd{_cnt(n), }\cmd{close_bkt_cnt(n), reset_bkt_cnt} functions to keep track of adding curly brackets as strings. \cmd{add} will return \cmd{n} (default 1) \{'s and increment a counter. \cmd{close} will return \cmd{n} \}'s (default will close all brackets) and decrement.\\
 \llcmd{_NumBkts} internal integer for tracking the number of brackets\\
 \llcmd{opencmd(cs)} prints \cmd{\cs}\{ and adds to the bracket counters.\\
@@ -166,7 +164,13 @@
 
 
 
+\subsubsection*{global extras}
+If \cmd{extrasglobals} is used and NOT \cmd{extras}, many additional globals are set for shortcuts\\
+All \cmd{pl.tex} modules are made global.\\
+\cmd{pl.hasval}, \cmd{pl.COMP}, \cmd{pl.utils.kpairs}, \cmd{pl.utils.npairs} become globals with the function name.\\
 
+
+
 \subsection*{Macro helpers}
 \cmd{\MakeluastringCommands[def]{spec}} will let \cmd{\plluastring(A|B|C..)} be \cmd{\luastring(N|O|T|F)}
 based on the letters that \cmd{spec} is set to (or \cmd{def} if nothing is provided)
@@ -221,11 +225,9 @@
 \end{LTXexample}
 
 
-\subsubsection*{global extras}
-If \cmd{extrasglobals} is used and NOT \cmd{extras}, many globals are set.\\
-All \cmd{pl.tex} modules are made global.\\
-\cmd{hasval}, \cmd{COMP}, \cmd{kpairs}, \cmd{npairs} are globals.\\
 
+
+
     \section*{}
     Disclaimer: I am not the author of the Lua Penlight library.
     Penlight is Copyright \textcopyright  2009-2016 Steve Donovan, David Manura.
@@ -233,5 +235,25 @@
 \url{https://github.com/lunarmodules/penlight}\\
     The author of this library has merged all Lua sub-modules into one file for this package.
 
-
+%  \tblfrkv{tbl_def}{kale=cool,paul=gay,craig=fun}
+%  \tblfrkv{tbl}{kale,paul=gay} %[naked_as_value=true]
+%
+%  \tblget{tbl}{kale}%
+%  \tblget{tbl}{paul}%
+%  \tblget{tbl}{craig}%
+%
+%  \tblupd{tbl_def}{tbl}%
+%
+%  \tblfrkvII{tbl}{kale=cool,paul=gay,craig=fun}{kale=weak,paul=sad}
+%  \tblget{tbl}{craig}%
+%  \tblget{tbl}{paul}%
+%  \tblget{tbl}{kale}%
+%
+%  \NewDocumentCommand{\THINg}{ O{} m}{%
+%    \tblfrkvII{setti}{color=red,size=small}{#1} % make settings and update based on [arg=]
+%    {\color{\tblget{setti}{color}}\tblget{setti}{size} #2}
+%  }
+%
+%  \THINg[color=blue,size=tiny]{Kale}
+  
 \end{document}
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/luatex/penlight/penlight.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/penlight/penlight.sty	2023-07-19 20:48:30 UTC (rev 67671)
+++ trunk/Master/texmf-dist/tex/luatex/penlight/penlight.sty	2023-07-19 20:48:38 UTC (rev 67672)
@@ -1,5 +1,5 @@
 % Kale Ewasiuk (kalekje at gmail.com)
-% 2022-10-24
+% 2023-07-18
 % Copyright (C) 2021-2022 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{penlight}[2022-10-24]
+\ProvidesPackage{penlight}[2023-07-18]
 
 \RequirePackage{luacode}
 
@@ -42,11 +42,15 @@
 \DeclareOption{stringx}{\luadirect{_G[__PENLIGHT__].stringx.import()}}
 \DeclareOption{format}{\luadirect{_G[__PENLIGHT__].stringx.format_operator()}}
 \DeclareOption{func}{\luadirect{_G[__PENLIGHT__].utils.import(__PENLIGHT__..'.func')}}
-\DeclareOption{extras}{\luadirect{require'penlightextras'}}
+\DeclareOption{extras}{\luadirect{require'penlightextras'}
+  \gdef\penlight at loadextras{}
+}
 \DeclareOption{extrasglobals}{\luadirect{
     __PL_GLOBALS__ = true
     require'penlightextras'
-}}
+  }
+  \gdef\penlight at loadextras{}
+}
 
 \ProcessOptions*\relax
 
@@ -56,10 +60,10 @@
 end
 }
 
+\ifdefined\penlight at loadextras
 
+\global\newcommand{\writePDFmetadata}{\luadirect{_G[__PENLIGHT__].tex.writePDFmetadata()}}
 
-\newcommand{\writePDFmetadata}{\luadirect{_G[__PENLIGHT__].tex.writePDFmetadata()}}
-
 \NewDocumentCommand{\writePDFmetadatakv}{ s m }{
 \IfBooleanTF{#1}{% if *, overwrite everything
   \luadirect{
@@ -74,8 +78,8 @@
 }
 
 
-\def\luastringT#1{\luastring{\unexpanded\expandafter\expandafter\expandafter{#1}}}  % expand luastring twice
-\let\luastringF\luastring  % fully expanded luastring
+\gdef\luastringT#1{\luastring{\unexpanded\expandafter\expandafter\expandafter{#1}}}  % expand luastring twice
+\global\let\luastringF\luastring  % fully expanded luastring
 
 % allow control over expansion of arguments to a latex function
 \NewDocumentCommand{\MakeluastringCommands}{O{} m }{% #1 the desired commands #2 defaults
@@ -90,4 +94,52 @@
 \NewDocumentCommand{\splitToItems}{ O{NN} m m }{%
   \MakeluastringCommands[nn]{#1}%
   \luadirect{_G[__PENLIGHT__].tex.split2items(\plluastringA{#2},\plluastringB{#3})}%
-}
\ No newline at end of file
+}
+
+
+%
+%
+%\NewDocumentCommand{\tblnew}{m}{\luadirect{
+%  _G[\luastring{#1}] = {}
+%}}
+%
+%\NewDocumentCommand{\tblfrkv}{m m O{} }{\luadirect{
+%  _G[\luastring{#1}] = luakeys.parse(\luastring{#2}, luakeys.parse(\luastring{#3}))
+%}}
+%
+%\NewDocumentCommand{\tblset}{m m m}{\luadirect{
+%  _G[\luastring{#1}][\luastring{#2}] = \luastring{#3}
+%}}
+%
+%\NewDocumentCommand{\tblget}{m m}{\luadirect{
+%  tex.sprint(tostring(_G[\luastring{#1}][\luastring{#2}]))
+%}}
+%
+%\NewDocumentCommand{\tblidx}{m m}{\luadirect{
+%  tex.sprint(tostring(_G[\luastring{#1}][#2]))
+%}}
+%
+%
+%\NewDocumentCommand{\tblupd}{ m m}{\luadirect{
+%  _G[__PENLIGHT__].tablex.update(_G[\luastring{#1}], _G[\luastring{#2}])
+%}}
+%
+%\NewDocumentCommand{\tblupdkv}{ m m }{\luadirect{
+%  _G[__PENLIGHT__].tablex.update(_G[\luastring{#1}], luakeys.parse(\luastring{#2}))
+%}}
+%
+%% todo need a get table function. If blank is passed, the last table referenced is used.
+%\NewDocumentCommand{\tblfrkvII}{ m m m }{\luadirect{
+%  _G[\luastring{#1}] = _G[__PENLIGHT__].tablex.update(luakeys.parse(\luastring{#2}), luakeys.parse(\luastring{#3}))
+%}}
+
+
+%\NewDocumentCommand{\tbldo}{m m O{} }{\luadirect{
+%  % tex.sprint(tostring(_G[\luastring{#1}][#2]))
+%  % todo allow one to use pl tablex function here,
+%  % {tbl}{update}[arg1][arg2]
+%  _G[__PENLIGHT__].tablex[\luastring[#1]](_G[\luastring{}], _G[\luastring{}])
+%}}
+
+
+\else\fi
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua	2023-07-19 20:48:30 UTC (rev 67671)
+++ trunk/Master/texmf-dist/tex/luatex/penlight/penlightextras.lua	2023-07-19 20:48:38 UTC (rev 67672)
@@ -1,5 +1,5 @@
 --% Kale Ewasiuk (kalekje at gmail.com)
---% 2022-10-24
+--% 2023-07-18
 --% Copyright (C) 2021-2022 Kale Ewasiuk
 --%
 --% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -28,14 +28,16 @@
 __PL_GLOBALS__ = __PL_GLOBALS__ or false
 __PL_EXTRAS__ = 1
 __PL_NO_HYPERREF__ = __PL_NO_HYPERREF__ or false
+-- __PENLIGHT__ = 'penlight' or 'pl'
 
 -- requires penlight
 local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl
 
 if not __PL_SKIP_LUAKEYS__ then
-    luakeys = require'luakeys'
+    luakeys = require'luakeys'()
 end
 
+
 -- some bonus string operations, % text operator, and functional programming
 pl.stringx.import()
 pl.stringx.format_operator()
@@ -311,7 +313,7 @@
         t = pl.tablex.map(string.trimfl, t)
     end
     t[#t+1] = r -- add the og return of label
-    pl.help_wrt(t, 'ref info')
+    --pl.help_wrt(t, 'ref info')
     return t
 end
 
@@ -511,7 +513,7 @@
 -- todo option for multiple filters with AND logic, like the filter files??
 function pl.tablex.filterstr(t, exp, case)
     -- case = case sensitive
-    case = hasval(case)
+    case = pl.hasval(case)
     -- apply lua patterns to a table to filter iter
     -- str or table of str's can be passed, OR logic is used if table is passed
     if case then
@@ -699,12 +701,11 @@
 pl.tex.add_xspace_intext = true
 
 
-function pl.tex.updatePDFtable(k, v, o)
+function pl.tex.updatePDFtable(k, v, o) -- key val overwrite
     k = k:upfirst()
-    if not pl.hasval(o) and __PDFmetadata__[k] ~= nil then
-        return
+    if pl.hasval(o) or (__PDFmetadata__[k] == nil) then
+        __PDFmetadata__[k] = v
     end
-    __PDFmetadata__[k] = v
 end
 
 pl.tex.writePDFmetadata = function(t) -- write PDF metadata to xmpdata file



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