Debian Codegraph @

texmf-dist/doc/luatex/penlightplus/penlightplus.tex

raw
1 % Kale Ewasiuk ([email protected])
2 % 2025-02-14
3 % Copyright (C) 2021-2025 Kale Ewasiuk
4 %
5 % Permission is hereby granted, free of charge, to any person obtaining a copy
6 % of this software and associated documentation files (the "Software"), to deal
7 % in the Software without restriction, including without limitation the rights
8 % to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 % copies of the Software, and to permit persons to whom the Software is
10 % furnished to do so, subject to the following conditions:
11 %
12 % The above copyright notice and this permission notice shall be included in
13 % all copies or substantial portions of the Software.
14 %
15 % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16 % ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17 % TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18 % PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19 % SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
20 % ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 % ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 % OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
23 % OR OTHER DEALINGS IN THE SOFTWARE.
24
25
26 \documentclass[11pt,parskip=half]{scrartcl}
27 \usepackage[default]{lato}
28 \setlength{\parindent}{0ex}
29 \newcommand{\llcmd}[1]{\leavevmode\llap{\texttt{\detokenize{#1}}}}
30 \newcommand{\cmd}[1]{\texttt{\detokenize{#1}}}
31 \newcommand{\qcmd}[1]{``\cmd{#1}''}
32 \usepackage{url}
33 \usepackage{xcolor}
34 \usepackage{showexpl}
35 \lstset{explpreset={justification=\raggedright,pos=r,wide=true}}
36 \setlength\ResultBoxRule{0mm}
37 \lstset{
38 language=[LaTeX]TeX,
39 basicstyle=\ttfamily\footnotesize,
40 commentstyle=\ttfamily\footnotesize\color{gray},
41 frame=none,
42 numbers=left,
43 numberstyle=\ttfamily\footnotesize\color{gray},
44 prebreak=\raisebox{0ex}[0ex][0ex]{\color{gray}\ensuremath{\hookleftarrow}},
45 extendedchars=true,
46 breaklines=true,
47 tabsize=4,
48 }
49 \addtokomafont{title}{\raggedright}
50 \addtokomafont{author}{\raggedright}
51 \addtokomafont{date}{\raggedright}
52 \author{Kale Ewasiuk (\url{[email protected]})}
53 \usepackage[yyyymmdd]{datetime}\renewcommand{\dateseparator}{--}
54 \date{\ \today}
55
56
57 \RequirePackage[pl,globals]{penlightplus}
58
59 \title{penlightplus}
60 \subtitle{Additions to the Penlight Lua Libraries}
61
62
63 \begin{document}
64 %
65
66 \maketitle
67
68 \section*{Package Options and Set-Up}
69
70 This package first loads the LaTeX \cmd{penlight[import]} package:\\
71 \url{https://ctan.org/pkg/penlight?lang=en}.\\
72 Documentation for the Lua penlight package can be found here:\\ \url{https://lunarmodules.github.io/Penlight/index.html}.\\
73 The \texttt{pl} option may be passed to this package to create an alias for \cmd{penlight}.\\
74 A portion of this package to facilitate the creation, modification, and usage of the Lua table data structure
75 through a LaTeX interface has been moved to a separate package called \cmd{luatbls}:\\
76 \url{https://ctan.org/pkg/luatbls}.
77
78
79 The following global Lua variables are defined:
80
81 \cmd{__SKIP_TEX__} If using the \cmd{penlightplus} package with \cmd{texlua} (good for troubleshooting), set this global before loading \cmd{penlight}\\
82 \cmd{__PL_GLOBALS__} If using this package with \cmd{texlua} and you want to set some functions as globals (described in next sections), set this variable to \cmd{true} before loading \cmd{penlight}\\
83 \cmd{__PL_NO_HYPERREF__} a flag used to change the behaviour of some functions, depending on if you don't use the hyperref package\\
84 \cmd{__PDFmetadata__} a table used to store PDF meta-data for pdfx package.
85
86
87 \subsubsection*{globals option}
88 Since this package uses the penlight \cmd{import} option,
89 all \cmd{stringx} functions are injected into the \cmd{string} meta-table and you can use them like so: \cmd{'first name':upfirst()}.
90 But if the package option \cmd{globals} is used, many additional globals are set for easier scripting.
91 \cmd{pl.hasval}, \cmd{pl.COMP}, \cmd{pl.utils.kpairs}, \cmd{pl.utils.npairs} become globals.
92 \cmd{pl.tablex} is aliased as \cmd{tbx} (which also includes all native Lua table functions), and
93 \cmd{pl.array2d} is aliased as \cmd{a2d}.
94
95 %If you want global \cmd{pl.tex} functions and variables, call \cmd{pl.make_tex_global()}.\\
96
97
98 \subsection*{texlua usage}
99 If you want to use \cmd{penlightplus.lua} with the \texttt{texlua} interpreter
100 (no document is made, but useful for testing your Lua code),
101 you can access it by setting \cmd{__SKIP_TEX__ = true} before loading. For example:
102 \begin{verbatim}
103 package.path = package.path .. ';'..'path/to/texmf/tex/lualatex/penlightplus/?.lua'
104 package.path = package.path .. ';'..'path/to/texmf/tex/lualatex/penlight/?.lua'
105 penlight = require'penlight'
106
107 __SKIP_TEX__ = true --only required if you want to use
108 --penlightplus without a LaTeX run
109 __PL_GLOBALS__ = true -- optional, include global definitions
110
111 require'penlightplus'
112
113 \end{verbatim}
114
115
116
117 \section*{penlight additions}
118
119 Some functionality is added to penlight and Lua.
120
121 \subsection*{General Additions}
122
123 \llcmd{pl.hasval(x)} Python-like boolean testing\\
124 \llcmd{COMP'xyz'()} Python-like comprehensions:\\\url{https://lunarmodules.github.io/Penlight/libraries/pl.comprehension.html}\\
125
126 \llcmd{_Gdot(s)} return a global (may contain dots) from string
127
128 \cmd{clone_function(f)} returns a cloned function\\
129 \cmd{operator.strgt(a,b)} compares strings a greater than b (useful for sorting)\\
130 \cmd{operator.strlt(a,b)} compares strings a less than b (useful for sorting)\\
131
132 \llcmd{math.mod(n,d)} math modulus\\
133 \cmd{math.mod2(n)} mod with base 2\\
134
135 \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\\
136
137 \llcmd{pl.}\cmd{trysplitcomma(s)} will try to split a string on comma (and strip), but if is a table, leave it
138
139 \llcmd{pl.}\cmd{findfiles{}} or \cmd{findfiles'kv'} is an updated version of \cmd{filterfiles}. Pass a table or a luakeys
140 kv string as the only argument. Valid table options are: \cmd{fn, dir, ext, sub}.
141
142 \llcmd{pl.}\cmd{char(n)} return letter corresponding to 1=a, 2=b, etc.\\
143 \llcmd{pl.}\cmd{Char(n)} return letter corresponding to 1=A, 2=B, etc.\\
144
145
146
147 \subsection*{string additions}
148
149 \begin{luacode*}
150 pl.wrth(('a = 1, b =2 '):split2('=',',',false))
151 \end{luacode*}
152
153 \llcmd{string.}\cmd{upfirst(s)} uppercase first letter\\
154 \llcmd{string.}\cmd{delspace(s)} delete all spaces\\
155 \llcmd{string.}\cmd{trimfl(s)}remove first and last chars\\
156 \llcmd{string.}\cmd{splitstrip(s, sp, st)} split by sp (default comma) followed by strip (default whitespace)\\
157 \llcmd{string.}\cmd{split2(s, sep1, sep2, st)} split a string twice (creates a 2d array), first by sep1 (default comma), then by sep2 (default =), with option to strip (default true)\\
158 \llcmd{string.}\cmd{appif(s, append, bool, alternate)}\\
159 \llcmd{string.}\cmd{gfirst(s, t)}return first matched patter from an array of patterns t\\
160 %\llcmd{string.}\cmd{gnum(s)} extract a number from a string\\
161 \llcmd{string.}\cmd{gextract(s,pat)} extract a pattern from a string (returns capture and new string with capture removed)\\
162 \llcmd{string.}\cmd{gextrct(s,pat,num,join)} extract a pattern from a string (returns capture and new string with capture removed),
163 can specify a number of extractions. if join is specified, captures will be joined, otherwise a list is returned\\
164 \llcmd{string.}\cmd{totable(s)} string a table of characters\\
165 \llcmd{string.}\cmd{tolist(s)} string a table of characters\\
166 \llcmd{string.}\cmd{containsany(s,t)} checks if any of the array of strings \cmd{t} are in \cmd{s} using \cmd{string.find}\\
167 \llcmd{string.}\cmd{containsanycase(s,t)} case-insensitive version\\
168 \llcmd{string.}\cmd{delspace(s)} clear spaces from string\\
169 \llcmd{string.}\cmd{subpar(s, c)} replaces \cmd{\\par} with a character of your choice default is space\\
170 \llcmd{string.}\cmd{istexdim(s)} checks if a string is a valid tex dimension (eg. mm, pt, sp)\\
171 \llcmd{string.}\cmd{fmt(s, t, fmt)} format a string like \cmd{format_operator}, but with
172 a few improvements. \cmd{t} can be an array (reference items like \cmd{\$1} in the string),
173 and \cmd{fmt} can be a table of formats (keys correspond to those in \cmd{t}), or a string that
174 is processed by luakeys.\\
175 \llcmd{string.}\cmd{parsekv(s, opts)} parse a string using a \cmd{luakeys} instance (\cmd{penlight.luakeys}). A kv-string or table can be used for opts.\\
176 \llcmd{string.}\cmd{hasnoalpha(s)} string has no letters\\
177 \llcmd{string.}\cmd{hasnonum(s)} string has no numbers\\
178 \llcmd{string.}\cmd{isvarlike(s)} string is 'variable-like', starts with a letter or underscore and then is alphanumeric or has underscores after \\
179 %\begin{luacode*}
180 % local s1, s2 = ('12,13'):gxtrct('%d',nil)
181 % pl.wrth({s1,s2}, 'err rat')
182 %--% pl.wrth(('_'):isvarlike(), 'llll')
183 %--% pl.wrth(('1_1k'):isvarlike(), ',,')
184 %--% pl.wrth(('kale_1'):isvarlike(), '')
185 %--% pl.wrth(('kale_1'):isvarlike(), '')
186 %\end{luacode*}
187
188 \subsection*{tablex additions}
189 \llcmd{tablex.}\cmd{fmt(t, f)} format a table with table or key-value string f\\
190 \llcmd{tablex.}\cmd{list2comma(t)} Use oxford comma type listing, e.g. A, B, and C\\
191 \llcmd{tablex.}\cmd{strinds(t)} convert integer indexes to string indices (1 -> '1')\\
192 \llcmd{tablex.}\cmd{filterstr(t,e,case)} keep only values in table t that contain expression e, case insensitive by default.\\
193 \llcmd{tablex.}\cmd{mapslice(f,t,i1,i2)} map a function to elements between i1 and i2\\
194 \llcmd{tablex.}\cmd{listcontains(t,v)} checks if a value is in a array-style list \\
195 \llcmd{tablex.}\cmd{kkeys(t)} returns keys that are non-numeric (like kpairs) \\
196 \llcmd{tablex.}\cmd{train(t,seq,reind)} return a sable based on \cmd{pl.seq.tbltrain}, \cmd{reind} will make numerical keys ordered from 1 \\
197
198 %\begin{luacode*}
199 % local t = {1,2,3,a='A',b='B'}
200 % penlight.wrth(penlight.tablex.train(t,'2:3,*',true),'kew')
201 %\end{luacode*}
202
203 \subsection*{List additions}
204 \llcmd{List:}\cmd{inject(l2, pos)} injects a list (l2) into a list at position. Set pos=0 to inject at end.
205 \begin{luacode*}
206 l = pl.List{1,2,3,4,5}
207 pl.wrth(l:inject({'a','b','c'},0), 'INJECTED')
208 \end{luacode*}
209
210 \begin{luacode*}
211 f = pl.findfiles'fn=pen*, ext=".lua, .sty, .pdf", sub=false'
212 pl.wrth(f, 'FILES')
213 --penlight.wrth(penlight.dir.getallfiles('.', '*pen*'), 'ALLFILES')
214 pl.wrth(pl.file.access_time('penlightplus'), 'ACCESS TIME')
215 pl.wrth(pl.file.access_time('penlightpluxs'), 'ACCESS TIME')
216 if xdasdsa == nil then
217 penlight.utils.on_error('error')
218 --texio.write_nl('LaTeX Warning: FK )')
219 -- return penlight.utils.raise('Invalid path was attempted')
220 -- penlight.utils.on_error('stop')
221 -- return penlight.utils.raise('...')
222 end
223 \end{luacode*}
224
225
226 \subsubsection*{seq additions}
227 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.\\
228 \llcmd{seq.}\cmd{prod(t1, t2)} iterate over the cartesian product of t1 and t2\\
229 \llcmd{seq.}\cmd{train(trn, len)} produces a pl.List according to the arguments\\
230 \llcmd{seq.}\cmd{itrain(trn, len)} produces an iterator according to the arguments.\\
231 \llcmd{seq.}\cmd{tbltrain(tbl, trn)} produces an iterator over a table
232
233 An example syntax for \cmd{trn} is \cmd{'i1, i2, r1:r2', etc.} where \cmd{i1} and \cmd{i2} are individual indexes/elements, separated by \cmd{,} and
234 \cmd{r1:r2} is a range (inclusive of end-point) denoted with a \cmd{:}. The range format follows python's numpy indexing, and
235 a 'stride' can be given by including a second colon like \cmd{::2 -> is 1,3,5,...}, or \cmd{2::3 -> 2,5,8,...}.
236 Negative numbers can be used to index relative to the length of the table, eg, \cmd{-1 -> len}, but
237 if length is not given, negative indexing cannot be used and a number after the first colon must be provided.
238 A missing left-number on the colon assumes \cmd{1}, and missing right number assumes \cmd{len}. A missing 'stride' (number after the optional second colon) assumes a value of 1.\\
239 Variable-like strings can be given in place of numbers, which are assumed to be keys for a table instead.\\
240 For \cmd{tbltrain} a \cmd{*} can be passed to iterate over all keys.
241
242 The default colon and comma separators for ranges and elements can be set with \cmd{seq.train_range_sep} and \cmd{seq.train_element_sep}, respectively.
243 \begin{LTXexample}[width=0.5\linewidth]
244 \begin{luacode*}
245 for i in
246 pl.seq.itrain('1, :, 6, 0::2, -3 ',
247 5) do
248 tex.print(i..',')
249 end
250 local t = {'n1','n2',a='A',b='B',c='C'}
251 for k, v in
252 pl.seq.tbltrain(t, '*,c,1') do
253 tex.print(tostring(k)..'='..tostring(v)..'; ')
254 end
255 \end{luacode*}
256 \end{LTXexample}
257
258
259
260 \subsection*{A \cmd{pl.tex.} module is added}
261 \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.\\
262 \llcmd{_NumBkts} internal integer for tracking the number of brackets\\
263 \llcmd{opencmd(cs)} prints \cmd{\cs}\{ and adds to the bracket counters.\\
264 \cmd{openenv(env,opts)} prints a \cmd{\begin{env}[opts]}, and stores the enironment in a list so it can be later closed with \cmd{closeenv{num}}
265 \\
266 \llcmd{xNoValue,}\cmd{xTrue,xFalse}: \cmd{xparse} equivalents for commands\\
267 \\
268 \llcmd{prt(x),prtn(x)} print without or with a newline at end. Tries to help with special characters or numbers printing.\\
269 \llcmd{prtl(l),prtt(t)} print a literal string, or table\\
270 \llcmd{wrt(x), wrtn(x)} write to log\\
271 \llcmd{wrth}\cmd{(s1, s2)} pretty-print something to console. S2 is a flag to help you find., alias is \cmd{help_wrt}, also in \cmd{pl.wrth}\\
272 \llcmd{prt_array2d(tt)} pretty print a 2d array\\
273 \\
274 \llcmd{pkgwarn}\cmd{(pkg, msg1, msg2)} throw a package warning\\
275 \llcmd{pkgerror}\cmd{(pkg, msg1, msg2, stop)} throw a package error. If stop is true, immediately ceases compile.\\
276 \\
277 \llcmd{defcmd}\cmd{(cs, val)} like \cmd{\gdef}, but note that no special chars allowed in \cmd{cs}(eg. \cmd{@})\\
278 \llcmd{defmacro}\cmd{(cs, val)} like \cmd{\gdef}, allows special characters, but any tokens in val must be pre-defined (this uses \cmd{token.set_macro} internally)\\
279 \llcmd{newcmd}\cmd{(cs, val)} like \cmd{\newcommand}\\
280 \llcmd{renewcmd}\cmd{(cs, val)} like \cmd{\renewcommand}\\
281 \llcmd{prvcmd}\cmd{(cs, val)} like \cmd{\providecommand}\\
282 \llcmd{deccmd}\cmd{(cs, dft, overwrite)} declare a command. If \cmd{dft} (default) is \cmd{nil}, \cmd{cs} is set
283 to a package warning saying \cmd{'cs' was declared and used in document, but never set}. If \cmd{overwrite}
284 is true, it will overwrite an existing command (using \cmd{defcmd}), otherwise, it will throw error like \cmd{newcmd}.\\
285 \\
286 \llcmd{get_ref_info(l)}accesses the \cmd{\r@label} and returns a table\\
287
288
289
290
291 \subsection*{Recording LaTeX input as a lua variable}
292 \cmd{penlight.tex.startrecording()} start recording input buffer without printing to latex\\
293 \cmd{penlight.tex.stoprecording()} stop recording input buffer\\
294 \cmd{penlight.tex.readbuf()} internal-use function that interprets the buffer. This will ignore an environment ending (eg. \cmd{end{envir}})\\\\
295 \cmd{penlight.tex.recordedbuf} the string variable where the recorded buffer is stored\\
296
297
298 \section*{penlightplus LaTeX Macros}
299
300
301 \subsection*{Macro helpers}
302 \cmd{\MakeluastringCommands[def]{spec}} will let \cmd{\plluastring(A|B|C..)} be \cmd{\luastring(N|O|T|F)}
303 based on the letters that \cmd{spec} is set to (or \cmd{def}(ault) if nothing is provided)
304 This is useful if you want to write a command with flexibility on argument expansion.
305 The user can specify \cmd{n}, \cmd{o}, \cmd{t}, and \cmd{f} (case insensitve) if they want
306 none, once, twice, or full expansion.
307
308 %\cmd{e} expansion expands every token in the argument only once.
309 %\cmd{\luastringE{m}}, expands each token once (note that \cmd{\luastringO} only expands the first token once)
310
311
312
313 Variants of luastring are added:\\
314 \cmd{\luastringF{m}} = \cmd{\luastring{m}} \\
315 \cmd{\luastringT{m}}, expand the first token of m twice\\
316
317 For example, we can control the expansion of args 2 and 3 with arg 1:
318
319 \begin{verbatim}
320 \NewDocumentCommand{\splittocomma}{ O{nn} m m }{%
321 \MakeluastringCommands[nn]{#1}%
322 \luadirect{penlight.tex.split2comma(\plluastringA{#2},\plluastringB{#3})}%
323 }
324 \end{verbatim}
325
326 % BELOW IS FOR TROUBLESHOOTING ABOVE
327 %\def\NOTexp{\ONEexp}
328 %\def\ONEexp{\TWOexp}
329 %\def\TWOexp{\TREexp}
330 %\def\TREexp{Fully expanded}
331 %
332 %\NewDocumentCommand{\luastringExpTest}{m m}{
333 % \MakeluastringCommands{#1}
334 % \luadirect{texio.write_nl('VVVVVVVVVVVVVVVVVVVVVVVVVVVVV')}
335 % \luadirect{texio.write_nl(\plluastringA{#2}..' | Not')}
336 % \luadirect{texio.write_nl(\plluastringB{#2}..' | Once')}
337 % \luadirect{texio.write_nl(\plluastringC{#2}..' | Twice')}
338 % \luadirect{texio.write_nl(\plluastringD{#2}..' | Full')}
339 % \luadirect{texio.write_nl('VVVVVVVVVVVVVVVVVVVVVVVVVVVVV')}
340 %}
341 %
342 %\luastringExpTest{ n o t f }{\NOTexp}
343
344
345 \subsection*{Lua boolean expressions}
346
347 \cmd{\ifluax{<Lua expr>}{<do if true>}[<do if false>]} and\\
348 \cmd{\ifluaxv{<Lua expr>}{<do if true>}[<do if false>]} for truthy (uses \cmd{penlight.hasval}). The argument is expanded.
349
350 \begin{LTXexample}[width=0.3\linewidth]
351 \ifluax{3^3 == 27}{3*3*3 is 27}[WRONG]\\
352 \ifluax{abc123 == nil}{Var is nil}[WRONG]\\
353 \ifluax{not true}{tRuE}[fAlSe]\\
354 \ifluax{''}{TRUE}[FALSE]\\
355 \ifluaxv{''}{true}[false]\\
356 \def\XXX{8}
357 \ifluax{\XXX == 8}{Yes}[No]
358 \end{LTXexample}
359
360 \subsection*{Case-switch for Conditionals}
361
362 \cmd{\caseswitch{case}{kev-val choices}} The starred version will throw an error if the case is not found.
363 Use \_\_ as a placeholder for a case that isn't matched. The case is fully expanded and interpreted as a lua string.
364
365 %TODO consider a case switch wth placeholder expressions? that would be cool. \_1 == 8 for example.
366
367 \begin{LTXexample}[width=0.3\linewidth]
368 \def\caseswitchexample{\caseswitch{\mycase}{dog=DOG, cat=CAT, __=INVALID}}
369 \def\mycase{dog} \caseswitchexample \\
370 \def\mycase{human} \caseswitchexample
371 \end{LTXexample}
372 %\caseswitch*{\mycase}{dog=DOG, cat=CAT, __=INVALID}
373
374
375
376
377
378
379
380
381
382 \subsection*{PDF meta data (for pdfx package)}
383 \cmd{\writePDFmetadatakv*[x]{kv}} Take a key-value string (eg. \cmd{title=whatever, author=me}) and then writes to the \cmd{jobname.xmpdata} file, which is used by pdfx.
384 \cmd{*} will first clear \cmd{__PDFmetadata__} which is the table variable that stores the metadata.
385 The un-starred version updates that table.
386 You can control the expansion of the key-val argument with \cmd{[x]}, which is fully expanded by default.
387 Command sequences are ultimately stripped from the values, except for \cmd{\and} is converted to \cmd{\sep} for pdfx usage (\url{https://texdoc.org/serve/pdfx/0}).
388 \\
389
390 \cmd{\writePDFmetadata} runs the lua function \cmd{penlight.tex.writePDFmetadata()},
391 which pushes the lua variable \cmd{__PDFmetadata__} (a table) to the xmpdata file.
392 This might be useful if you're updating \cmd{__PDFmetadata__} by some other means.
393
394 \def\thekeywords{A\and B\and C}
395 \def\thekeywords{ABC}
396 \begin{LTXexample}
397 \writePDFmetadatakv{author=Some One} %
398 \writePDFmetadatakv*[n]{author=Kale \and You\xspace} % Overwrites above. Does not expant kv
399 \writePDFmetadatakv{date=2024-02-01}
400 \end{LTXexample}
401
402
403
404 %\writePDFmetadatakv{datxe=2024-02-01} % would throw error, invalid key
405 %\writePDFmetadatakv[E]{keywords=\thekeywords} %
406
407 %\luadirect{texio.write_nl(\luastringE{keywords=\thekeywords})}
408
409
410
411
412 %%%%% SAND BOX
413 %
414 %\xtokcycleenvironment\luastringAenv
415 % {\addcytoks{##1}}
416 % {\processtoks{##1}}
417 % {\addcytoks[1]{##1}}
418 % {\addcytoks{##1}}
419 % {}
420 % {\cytoks\expandafter{\expandafter\luastringO\expandafter{\the\cytoks}}}
421 %
422 %\def\luastringA#1{\luastringAenv#1\endluastringAenv}
423 %\def\zzz{Hi Mom}
424 %\NewDocumentCommand{\testcommand}{m}{%
425 % \luastringA{#1} % this works as requested :)
426 %% \luadirect{texio.write_nl(\luastringA{#1}..' <<<')}
427 % }
428 %
429 %\luastringA{Hmmm. \zzz.}
430 %\testcommand{Hmmm. \zzz.}
431
432
433
434
435
436
437
438
439 % todo why isnt this working???
440
441
442
443
444
445
446 %\writePDFmetadatakv{datxe=2024-02-01} % would throw error, invalid key
447 %\writePDFmetadatakv[E]{keywords=\thekeywords} %
448
449 %\luadirect{texio.write_nl(\luastringE{keywords=\thekeywords})}
450
451
452
453
454 %%%%% SAND BOX
455 %
456 %\xtokcycleenvironment\luastringAenv
457 % {\addcytoks{##1}}
458 % {\processtoks{##1}}
459 % {\addcytoks[1]{##1}}
460 % {\addcytoks{##1}}
461 % {}
462 % {\cytoks\expandafter{\expandafter\luastringO\expandafter{\the\cytoks}}}
463 %
464 %\def\luastringA#1{\luastringAenv#1\endluastringAenv}
465 %\def\zzz{Hi Mom}
466 %\NewDocumentCommand{\testcommand}{m}{%
467 % \luastringA{#1} % this works as requested :)
468 %% \luadirect{texio.write_nl(\luastringA{#1}..' <<<')}
469 % }
470 %
471 %\luastringA{Hmmm. \zzz.}
472 %\testcommand{Hmmm. \zzz.}
473
474
475 %
476
477 %\pyth{} % erro
478
479
480
481
482 \end{document}