diff options
author | Norbert Preining <norbert@preining.info> | 2022-10-16 03:02:53 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2022-10-16 03:02:53 +0000 |
commit | 84ccc4dcda9db6735202d4ed21610de28392e708 (patch) | |
tree | 5572dd71e0688f59f52d89e22864ae162c88d365 /macros/luatex/generic/penlight/penlight.tex | |
parent | 716f66d13d38e113c2d0491804fae5879de67bb3 (diff) |
CTAN sync 202210160302
Diffstat (limited to 'macros/luatex/generic/penlight/penlight.tex')
-rw-r--r-- | macros/luatex/generic/penlight/penlight.tex | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/macros/luatex/generic/penlight/penlight.tex b/macros/luatex/generic/penlight/penlight.tex index f1c07a00cb..869fda37ed 100644 --- a/macros/luatex/generic/penlight/penlight.tex +++ b/macros/luatex/generic/penlight/penlight.tex @@ -1,5 +1,5 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2022-04-16 +% 2022-10-15 % Copyright (C) 2021-2022 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy @@ -76,12 +76,13 @@ If you want to use Penlight (and extras) with the \texttt{texlua} intrepreter (n you can access it by setting \cmd{__SKIP_TEX__ = true} and adding the package to path. For example: \begin{verbatim} package.path = package.path .. ';'..'path/to/texmf/tex/latex/penlight/?.lua' -penlight = require('penlight') +penlight = require'penlight' -- below is optional __SKIP_TEX__ = true --only required if you want to use --penlightextras without a LaTeX run -- __PL_NO_GLOBALS__ = true -- optional, skip global definitions -require('penlightextras') +__SKIP_LUAKEYS__ = true -- luakeys is laoded in penlightextras be default, you may skip it with this +require'penlightextras' \end{verbatim} \pagebreak @@ -118,8 +119,13 @@ If \cmd{extras} is used, the following Lua globals will be defined:\\ \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\\ +\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\\ \pagebreak @@ -148,7 +154,47 @@ If \cmd{extras} is used, the following Lua globals will be defined:\\ to a package warning saying \cmd{'cs' was declared and used in document, but never set}. If \cmd{overwrite} is true, it will overwrite an existing command (using \cmd{defcmd}), otherwise, it will throw error like \cmd{newcmd}.\\ +\subsection{Split stuff} +splitToComma: +-\splitToComma{ j doe }{\and}-\\ +-\splitToComma{ j doe \and s else }{\and}-\\ +-\splitToComma{ j doe \and s else \and a per }{\and}-\\ +-\splitToComma{ j doe \and s else \and a per \and f guy}{\and}- + +\def\authors{j doe \and s else \and a per \and f guy} +\splitToComma[o]{\authors}{\and} + + +spliToItems: +\begin{itemize} + \splitToItems{kale\and john}{\and} + \splitToItems{kale -john -someone else}{-} +\end{itemize} + +\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) +This is useful if you want to write a command with flexibility on argument expansion. +The user can specify \cmd{n}, \cmd{o}, \cmd{t}, and \cmd{f} (case insensitve) if they want +no, once, twice, or full expansion. + + +\def\NOTexp{\ONEexp} +\def\ONEexp{\TWOexp} +\def\TWOexp{\TREexp} +\def\TREexp{Fully expanded} + +\NewDocumentCommand{\luastringExpTest}{m m}{ + \MakeluastringCommands{#1} + \luadirect{texio.write_nl('VVVVVVVVVVVVVVVVVVVVVVVVVVVVV')} + \luadirect{texio.write_nl(\plluastringA{#2}..' | Not')} + \luadirect{texio.write_nl(\plluastringB{#2}..' | Once')} + \luadirect{texio.write_nl(\plluastringC{#2}..' | Twice')} + \luadirect{texio.write_nl(\plluastringD{#2}..' | Full')} + \luadirect{texio.write_nl('VVVVVVVVVVVVVVVVVVVVVVVVVVVVV')} +} +\luastringExpTest{ n o t f }{\NOTexp} \subsubsection*{global extras} If \cmd{extras} is used and NOT \cmd{extrasnoglobals}, then some globals are set.\\ |