summaryrefslogtreecommitdiff
path: root/macros/luatex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-07-20 03:00:54 +0000
committerNorbert Preining <norbert@preining.info>2023-07-20 03:00:54 +0000
commit16b3f7ad411e343f19c82febffd51601bbe90d3f (patch)
treeb7de45527fdfa95834c086d9fd6109133e86a202 /macros/luatex
parentd3bd608be0e8ac816c5d16ef32b4e046f869713f (diff)
CTAN sync 202307200300
Diffstat (limited to 'macros/luatex')
-rw-r--r--macros/luatex/generic/lutabulartools/lutabulartools.lua53
-rw-r--r--macros/luatex/generic/lutabulartools/lutabulartools.pdfbin116020 -> 112601 bytes
-rw-r--r--macros/luatex/generic/lutabulartools/lutabulartools.sty71
-rw-r--r--macros/luatex/generic/lutabulartools/lutabulartools.tex59
-rw-r--r--macros/luatex/generic/penlight/penlight.pdfbin59499 -> 60005 bytes
-rw-r--r--macros/luatex/generic/penlight/penlight.sty70
-rw-r--r--macros/luatex/generic/penlight/penlight.tex56
-rw-r--r--macros/luatex/generic/penlight/penlightextras.lua17
-rw-r--r--macros/luatex/latex/luaplot/luaplot.pdfbin147391 -> 147449 bytes
-rw-r--r--macros/luatex/latex/luaplot/luaplot.sty9
-rw-r--r--macros/luatex/latex/yamlvars/yamlvars.lua193
-rw-r--r--macros/luatex/latex/yamlvars/yamlvars.pdfbin83238 -> 82561 bytes
-rw-r--r--macros/luatex/latex/yamlvars/yamlvars.sty85
-rw-r--r--macros/luatex/latex/yamlvars/yamlvars.tex43
14 files changed, 291 insertions, 365 deletions
diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.lua b/macros/luatex/generic/lutabulartools/lutabulartools.lua
index 719f89873e..3ea2151834 100644
--- a/macros/luatex/generic/lutabulartools/lutabulartools.lua
+++ b/macros/luatex/generic/lutabulartools/lutabulartools.lua
@@ -1,5 +1,5 @@
--% Kale Ewasiuk (kalekje@gmail.com)
---% 2022-11-29
+--% 2023-07-18
--% Copyright (C) 2021-2022 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -25,7 +25,7 @@
local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl
if (__PL_EXTRAS__ == nil) or (__PENLIGHT__ == nil) then
- tex.sprint('\\PackageError{yamlvars}{penlight package with extras (or extrasglobals) option must be loaded before this package}{}')
+ tex.sprint('\\PackageError{lutabulartools}{penlight package with extras (or extrasglobals) option must be loaded before this package}{}')
tex.print('\\stop')
end
local T = pl.tablex
@@ -93,7 +93,6 @@ function lutabt.debugtalk(s, ss)
end
function __lutabt__debugprtall()
- --pl.help_wrt(pl.tablex.filter({ lutabt }, function(v) return type(v) ~= 'function' end), '(lutabulartools state)')
pl.help_wrt(lutabt, '(lutabulartools state)')
end
@@ -420,10 +419,10 @@ end
-----
lutabt.mrX = {}
-lutabt.mrX.resets = {long=false, longhead=0, cntr=0, head=nil, longx=false, on=true} -- settings that reset when \setmidruleX used
+lutabt.mrX.resets = {long=false, cntr=0, head=nil, longx=false, on=true} -- settings that reset when \setmidruleX used
lutabt.mrX.resets['head*'] = nil
lutabt.mrX.settings = T.update(T.copy(lutabt.mrX.resets), {pgcntr=0, step=5, rule='midrule'}) -- current settings, not overwritten with each call
-
+lutabt.mrX.settings.on = false
function lutabt.mrX.reset_midruleX(n)
lutabt.mrX.settings.cntr = tonumber(n)
@@ -459,7 +458,7 @@ function lutabt.mrX.midruleX(n)
lutabt.debugtalk(lutabt.mrX.settings, 'midruleX here')
local s = lutabt.mrX.settings
local rule = s.rule
- if pl.hasval(s.long) and lutabt.mrX.add_label_and_check_page_change() then lutabt.mrX.settings.cntr = -1*s.longhead end -- reset to number on page change
+ if pl.hasval(s.long) and lutabt.mrX.add_label_and_check_page_change() then lutabt.mrX.settings.cntr = 0 end -- reset to number on page change -- longhead not used anymore
lutabt.mrX.settings.cntr = lutabt.mrX.settings.cntr + 1
if lutabt.mrX.settings.cntr == s.step then
if not rule:startswith('\\') then rule = '\\'..rule end -- todo consider allowing \gmidrule syntax, possible issue with expansion
@@ -498,45 +497,3 @@ return lutabt -- lutabulartools
-
---
---lutabt.tabular_row_pages_cntr = 0
---function lutabt.reset_midruleX_on_newpage(n)
--- local n = n or 0
--- lutabt.tabular_row_pages_cntr = lutabt.tabular_row_pages_cntr + 1
--- tex.print('\\noalign{\\label{tabular@row@'..lutabt.tabular_row_pages_cntr..'}}')
--- if lutabt.get_ref_page('tabular@row@'..lutabt.tabular_row_pages_cntr) -
--- lutabt.get_ref_page('tabular@row@'..(lutabt.tabular_row_pages_cntr-1)) == 1 then
--- tex.print('\\setcounter{midruleX}{'..n..'}')
--- end
---end
-
-
---help_wrt('TEST COL ')
---for _, s in ipairs{ 'll', '*{6}{s}', 'l*{6}{l}', 'lll', 'll[]', 'll[]*{6}{l}', '*{6}{l}', 'y*{6}{sq}x', } do
--- lutabt. set_col_spec(s)
--- help_wrt(lutabt.col_spec,s)
---end
-
-
--- todo move mrX mechanim to avoid @{}
---function lutabt.mrX.set_midruleX(new_sett, def)
--- def = def or ''
--- local curr_sett = {}
--- if def == pl.tex._xTrue then -- default flag, if true, reset all non-used keys to default
--- curr_sett = lutabt.mrX.defaults
--- else
--- curr_sett = lutabt.mrX.settings
--- end
--- new_sett = luakeys.parse(new_sett)
--- lutabt.mrX.settings = T.union(curr_sett, new_sett)
---
--- lutabt.debugtalk(lutabt.mrX.settings, 'new midruleX settings')
--- lutabt.mrX.settings.cntr = tonumber(curr_sett.cntr) -- todo this needs to be a settings var
--- if new_sett.cntr ~= nil then -- todo fix the counter
--- lutabt.mrX.settings.cntr = tonumber(new_sett.cntr)
--- end
--- if new_sett.head ~= nil then -- todo fix the counter
--- lutabt.mrX.settings.cntr = -1*tonumber(new_sett.head)
--- end
---end
diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.pdf b/macros/luatex/generic/lutabulartools/lutabulartools.pdf
index 74c3446796..6443b2873a 100644
--- a/macros/luatex/generic/lutabulartools/lutabulartools.pdf
+++ b/macros/luatex/generic/lutabulartools/lutabulartools.pdf
Binary files differ
diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.sty b/macros/luatex/generic/lutabulartools/lutabulartools.sty
index 4ca3752578..c1e74802c0 100644
--- a/macros/luatex/generic/lutabulartools/lutabulartools.sty
+++ b/macros/luatex/generic/lutabulartools/lutabulartools.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2022-11-29
+% 2023-07-18
% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -23,10 +23,11 @@
% OR OTHER DEALINGS IN THE SOFTWARE.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lutabulartools}[2022-11-29]
+\ProvidesPackage{lutabulartools}[2023-07-18]
\RequirePackage{booktabs}
\RequirePackage{multirow}
+\RequirePackage{longtable}
\RequirePackage{makecell}
\RequirePackage{xparse}
\RequirePackage{array}
@@ -235,69 +236,3 @@
\ProcessOptions
-
-
-
-
-
-%%% OLD STUFF,
-%% before I had a fall-back for counting columns (just calculate current column on last column once)
-%% and kept track of row numbers. I felt that this wasn't needed, so I've removed.
-%\newcommand{\TabColNum}{\luadirect{tex.print(lutabt.get_TabColNum())}} % prints the current column number of tabular
-%\newcommand{\NumTabCols}{\luadirect{tex.print(lutabt.NumTabCols)}} % prints the total num columns of tabular
-%\newcounter{RowNumCnt}
-%\setcounter{RowNumCnt}{1}
-% \setcounter{RowNumCnt}{1}%
-% \luadirect{lutabt.NumTabColsMX = 0}% fall back if calc doesnt work for some reason
-% \setcounter{RowNumCnt}{1}%
-% \luadirect{lutabt.NumTabColsMX = 0}% fall back if calc doesnt work for some reason
-%\DeclareOption{notrimx}{
-% \global\newcolumntype{\lttltrim}{!{\stepcounter{RowNumCnt}}}
-%% \global\newcolumntype{\lttrtrim}{!{\luadirect{lutabt.get_TabColNum()}}}
-%}
-%\DeclareOption{trimx}{
-% \newcolumntype{\lttltrim}{@{\stepcounter{RowNumCnt}}}
-%% \newcolumntype{\lttrtrim}{@{\luadirect{lutabt.get_TabColNum()}}}
-%}
-
-
-%% adapted from
-% https://tex.stackexchange.com/questions/182953/add-midrule-every-5-lines-automatically
-%% https://tex.stackexchange.com/questions/145084/what-is-the-function-of-noalign
-%
-%\def\midruleXstep{5}
-%\def\midruleXrule{\gmidrule}
-%
-%\newcounter{midruleX}
-%\newcommand*{\midruleXa}{%
-% \aftergroup\aftergroup\aftergroup\midruleXaux
-%}
-%
-%\newif\ifmidruleX
-%
-%\newcommand*{\midruleXaux}{%
-% \noalign{%
-% \stepcounter{midruleX}%
-% \ifnum\value{midruleX}=\midruleXstep %
-% \global\midruleXtrue
-% \resetmidruleX%
-% \else
-% \global\midruleXfalse
-% \fi
-% }
-% \ifmidruleX\midruleXrule\fi
-%}
-
-%\newcommand*{\resetmidruleX}{\setcounter{midruleX}{0}} %
-%\resetmidruleX
-
-%\NewDocumentCommand{\resetmidruleXonNP}{O{0}}{\luadirect{lutabt.reset_midruleX_on_newpage(\luastring{#1})}}
-
-%
-%\NewDocumentCommand{\IfmidruleX}{m m}{% if a midruleX was placed, do #1, if not, do #2
-% \ifnum\the\value{midruleX}=0
-% #1
-% \else
-% #2
-% \fi%
-%} \ No newline at end of file
diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.tex b/macros/luatex/generic/lutabulartools/lutabulartools.tex
index 25acf21e25..9be8dbd330 100644
--- a/macros/luatex/generic/lutabulartools/lutabulartools.tex
+++ b/macros/luatex/generic/lutabulartools/lutabulartools.tex
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2022-11-29
+% 2023-07-18
% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -84,8 +84,6 @@
\begin{document}
-% todo: can improve naming... set col spec to a table instead of a string
-
\maketitle
\cmd{lutabulartools} is a package that contains a few useful Lua\LaTeX-based macros to help with tables.
@@ -169,7 +167,7 @@ Examples:\\
\cmd{\MC[+,2]}, if placed in the second column, occupies the second column to the end of the table and is two rows tall.\\
In any of these examples, you can place the alignment letters anywhere.
So, \cmd{\MC[l1,2b]} and \cmd{\MC[1,2 lb]} are both left-bottom aligned (spaces are ignored).\\
-Put an \cmd{_} as the last thing to add a \cmd{cmidrule} under, followed by a trim spec (the thing that goes in \cmd{()})
+Put an \cmd{_} as the last thing to add a \cmd{cmidrule} under, followed by a trim spec (the thing that goes in \cmd{cmidrule()})
\cmd{\MC[+c_l]} will add a \cmd{cmidrule} underneath the cell (which fills until the end of the table), with the left side trimmed.
\llcmd{[override mc]}%
@@ -344,18 +342,20 @@ Here's an example:
With this command, you can place a rule
every X rows for the next table made (place command outside of table).
You can configure the step size and what kind of midrule you prefer with the following key-val syntax, with default values below:\\
-\cmd{\midruleX{step=5,rule=midrule,cntr=0,head=0,long=false,longhead=0}}\\
-\cmd{step} is the number of rows (X) before applying the rule set by \cmd{rule}. \\
-Concering \cmd{longtable}s: If \cmd{long} is set to \cmd{true} (or the key is present),
-\cmd{\midruleX} will also add a unique \cmd{\label{}} on each row, and if the row starts on a newpage,
-resets the row counter to -1*\cmd{longhead}, to ensure you have the same X number of rows after the header of each page of a \cmd{longtable}.\\
+\cmd{\midruleX{step=5,rule=midrule,cntr=0,head=0,long=false}}\\
+\cmd{step} is the number of rows before applying the rule set by \cmd{rule}. \\
+
+Concerning \cmd{longtable}s: If \cmd{long} is set to \cmd{true} (or the key is present),
+\cmd{\midruleX} will also add a unique \cmd{\label{}} on each ro (to detect page changes), and if the row starts on a newpage,
+resets the row counter.
+
Use optional parameter \cmd{\midruleX*[o|n|f]{}}
to control expansion of the key-val settings (\cmd{[n]} for not expanded is default).
Before you want counting to begin, or anywhere in the table, you could
-apply \cmd{\resetmidruleX[cntr]} (\cmd{cnter} is incremented each row) to avoid header
-rows being counted and set the row \cmd{cntr} to an arbitrary value.
+apply \cmd{\resetmidruleX[cntr]} to an arbitrary value: \cmd{cntr} is normally incremented by 1 each row.
+You may want to avoid header rows being counted, or rows being underlined near the end of a table, for example.
If you want to skip the first \cmd{x} rows with \cmd{\midruleX}, set \cmd{head=x} (which is equivalent to \cmd{cntr=-x}).
-If you want to add a \cmd{midrule} under row \cmd{x}, use \cmd{head*=x} instead.
+If you want to skip the auto-ruling at that ro \cmd{x} (say a gray one) and instead use a \cmd{midrule}, use \cmd{head*=x}.
Note: Use \cmd{\noalign{\resetmiduleX}} if you need place a rule on the same line the reset takes place (ie. in a cell before \cmd{\\}).
@@ -421,15 +421,14 @@ Here's an example with long table. Notice the gray rules reliably appear 3 rows
\end{verbatim}
\midruleX{long=true,rule="\gcmidrules{1r,2-}"}
-\def\tblhead{\toprule No & Name & Place & other\\\midrule}
-\def\tblcontinued{\MC[+l]{Continued...}\\}
+\def\tblhead{\toprule No & Name & Place & other\\\\\midrule}
+\def\tblcontinued{\MC[+l]{...\\Continued...}\\\noalign{\resetmidruleX} } % reset added to avoid line in header
\def\tblcontinues{\MC[+r]{...Continues}\\}
\begin{longtable}{rclc}
\tblhead\endfirsthead
\tblcontinued\tblhead\endhead % all the lines above this will be repeated on every page
\tblcontinues\endfoot
\bottomrule End.\endlastfoot
- \resetmidruleX
1 & & & \\
2 & \MC[_]{hi} & & \\
3 & & & \\
@@ -451,31 +450,11 @@ Here's an example with long table. Notice the gray rules reliably appear 3 rows
19 & & & \\
\end{longtable}
-%\begin{tabular}{ll}
-% a \\
-% b \\
-% v \\
-% d \\
-% r \\
-%\end{tabular}
-
-Long table X example
-
-\LTXtable{\linewidth}{ltxexample}
-
-%\luadirect{pl.help_wrt(lutabt.actlvl, 'actlevel')}
-%\luadirect{pl.help_wrt(lutabt.row_num, 'row')}
-%\lttdebugprt
-
-%\settabular{tbrule} % glitch with LTX
-%\midrulesat{1,2,3}
-%\begin{tabular}{ll}
-% a \\
-% b \\
-% c \\
-% d \\
-% e \\
-%\end{tabular}
+
+%Long table X example
+%\LTXtable{\linewidth}{ltxexample}
+
+
\end{document}
diff --git a/macros/luatex/generic/penlight/penlight.pdf b/macros/luatex/generic/penlight/penlight.pdf
index d8a0ac2f15..a063e8922a 100644
--- a/macros/luatex/generic/penlight/penlight.pdf
+++ b/macros/luatex/generic/penlight/penlight.pdf
Binary files differ
diff --git a/macros/luatex/generic/penlight/penlight.sty b/macros/luatex/generic/penlight/penlight.sty
index 8180a839ac..4f5900e3b8 100644
--- a/macros/luatex/generic/penlight/penlight.sty
+++ b/macros/luatex/generic/penlight/penlight.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@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@loadextras{}
+}
\DeclareOption{extrasglobals}{\luadirect{
__PL_GLOBALS__ = true
require'penlightextras'
-}}
+ }
+ \gdef\penlight@loadextras{}
+}
\ProcessOptions*\relax
@@ -56,9 +60,9 @@ if __PENLIGHT__ == nil then
end
}
+\ifdefined\penlight@loadextras
-
-\newcommand{\writePDFmetadata}{\luadirect{_G[__PENLIGHT__].tex.writePDFmetadata()}}
+\global\newcommand{\writePDFmetadata}{\luadirect{_G[__PENLIGHT__].tex.writePDFmetadata()}}
\NewDocumentCommand{\writePDFmetadatakv}{ s m }{
\IfBooleanTF{#1}{% if *, overwrite everything
@@ -74,8 +78,8 @@ end
}
-\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 @@ end
\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
diff --git a/macros/luatex/generic/penlight/penlight.tex b/macros/luatex/generic/penlight/penlight.tex
index dad50c7be2..edba4933e8 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-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,33 +112,32 @@ require'penlightextras'
\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__}\\
\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\\
\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,6 +164,12 @@ is true, it will overwrite an existing command (using \cmd{defcmd}), otherwise,
+\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)}
@@ -221,10 +225,8 @@ spliToItems:
\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.
@@ -233,5 +235,25 @@ All \cmd{pl.tex} modules are made global.\\
\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
diff --git a/macros/luatex/generic/penlight/penlightextras.lua b/macros/luatex/generic/penlight/penlightextras.lua
index 7d0a7eb6b5..5f5f76aefb 100644
--- a/macros/luatex/generic/penlight/penlightextras.lua
+++ b/macros/luatex/generic/penlight/penlightextras.lua
@@ -1,5 +1,5 @@
--% Kale Ewasiuk (kalekje@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_SKIP_LUAKEYS__ = __PL_SKIP_LUAKEYS__ or false
__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 @@ function pl.tex.get_ref_info(l)
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 @@ pl.array2d.map_slice1 = pl.tablex.map_slice
-- 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 @@ __PDFmetadata__ = {}
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
diff --git a/macros/luatex/latex/luaplot/luaplot.pdf b/macros/luatex/latex/luaplot/luaplot.pdf
index 2217258723..1378aa6e29 100644
--- a/macros/luatex/latex/luaplot/luaplot.pdf
+++ b/macros/luatex/latex/luaplot/luaplot.pdf
Binary files differ
diff --git a/macros/luatex/latex/luaplot/luaplot.sty b/macros/luatex/latex/luaplot/luaplot.sty
index f9f5377c90..b148c5bdfe 100644
--- a/macros/luatex/latex/luaplot/luaplot.sty
+++ b/macros/luatex/latex/luaplot/luaplot.sty
@@ -1,9 +1,9 @@
% luaplot package
-% version 1.2
+% version 1.3
% Licensed under LaTeX Project Public License v1.3c or later. The complete license text is available at http://www.latex-project.org/lppl.txt.
%Authors: Chetan Shirore and Ajit Kumar
-\ProvidesPackage{luaplot}[1.2]
+\ProvidesPackage{luaplot}[1.3]
\RequirePackage{xkeyval}
\RequirePackage{luacode}
\RequirePackage{tikz}
@@ -110,13 +110,14 @@ for subexp in string.gmatch(\luastring{#2}, '([^,]+)') do
end
local colortbl={}
local countclr = 1
-for funcolor in string.gmatch(\mop@eight, '([^,]+)') do
+for funcolor in string.gmatch(\mop@eight, '[^,]*') do
+ if funcolor == nil or funcolor=='' then funcolor='black' end
colortbl[countclr] = funcolor
countclr = countclr + 1
end
local plotstytbl={}
local countplotsty = 1
-for funplotsty in string.gmatch(\mop@nine, '([^,]+)') do
+for funplotsty in string.gmatch(\mop@nine, '[^,]*') do
plotstytbl[countplotsty] = funplotsty
countplotsty = countplotsty + 1
end
diff --git a/macros/luatex/latex/yamlvars/yamlvars.lua b/macros/luatex/latex/yamlvars/yamlvars.lua
index 01b326c4b4..1d0da9a312 100644
--- a/macros/luatex/latex/yamlvars/yamlvars.lua
+++ b/macros/luatex/latex/yamlvars/yamlvars.lua
@@ -1,5 +1,5 @@
--% Kale Ewasiuk (kalekje@gmail.com)
---% 2022-11-06
+--% 2023-07-18
--% Copyright (C) 2021-2022 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -23,63 +23,65 @@
--% OR OTHER DEALINGS IN THE SOFTWARE.
--- tinyyaml license
---MIT License
---
---Copyright (c) 2017 peposso
---
---Permission is hereby granted, free of charge, to any person obtaining a copy
---of this software and associated documentation files (the "Software"), to deal
---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, subject to the following conditions:
---
---The above copyright notice and this permission notice shall be included in all
---copies or substantial portions of the Software.
---
---THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
---IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
---FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
---AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
---LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
---OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
---SOFTWARE.
YAMLvars = {} -- self table
-YAMLvars.yaml = require'markdown-tinyyaml' -- note: YAMLvars.sty will have checked existence of this already
+YAMLvars.yaml = require'tinyyaml' -- note: YAMLvars.sty will have checked existence of this already
+
+local luakeys = require'luakeys'() -- note: YAMLvars.sty will have checked existence of this already
local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl
if (__PL_EXTRAS__ == nil) or (__PENLIGHT__ == nil) then
tex.sprint('\\PackageError{yamlvars}{penlight package with extras (or extrasnoglobals) option must be loaded before this package}{}')
end
+-- UI tables to extend functionality
YAMLvars.xfm = {}
YAMLvars.prc = {}
YAMLvars.dec = {} -- table of declare function
+-- internal variables
YAMLvars.varsvals = {}
YAMLvars.varspecs = {}
YAMLvars.varslowcase = pl.List()
-YAMLvars.xfmDefault = {}
-YAMLvars.prcDefault = 'gdef'
-YAMLvars.dftDefault = nil
-
-YAMLvars.allowUndeclared = false
-YAMLvars.overwritedefs = false
-YAMLvars.lowvasevarall = false
-
YAMLvars.valTemp = ''
YAMLvars.varTemp = ''
-YAMLvars.tabmidrule = 'hline'
YAMLvars.debug = false
+YAMLvars.setts = {}
+YAMLvars.setts.undeclared = false
+YAMLvars.setts.overwrite = false
+YAMLvars.setts.lowercase = false
+YAMLvars.setts.tabmidrule = 'midrule'
+YAMLvars.setts.xfm = {}
+YAMLvars.setts.prc = 'gdef'
+YAMLvars.setts.dft = ''
+
+YAMLvars.settsdefault = pl.tablex.deepcopy(YAMLvars.setts)
+
+function YAMLvars.setts2default()
+ YAMLvars.setts = pl.tablex.deepcopy(YAMLvars.settsdefault)
+end
+
+function YAMLvars.updatesettskv(kv, res, def)
+ def = def or false
+ ss = 'setts' -- setts or settsdefault
+ if def then ss = 'settsdefault' end
+ if res == pl.tex._xTrue then
+ YAMLvars.setts2default()
+ end
+
+ local kv = luakeys.parse(kv)
+ if type(kv.xfm) == 'string' then
+ kv.xfm = pl.stringx.split(kv.xfm)
+ end
+ pl.tablex.update(YAMLvars[ss], kv)
+end
function YAMLvars.debugtalk(s, ss)
if YAMLvars.debug then
@@ -93,12 +95,6 @@ end
-
--- todo need distinction beyyween table and penlight list ???
- --val = pl.array2d.map_slice1(_1..'\\\\', val, 1,-2)
- --return val:join('')
- --return pl.tablex.reduce(_1.._2, val, '')
-
function YAMLvars.xfm.markdown(var, val)
--return '\\begin{markdown} '..val..'\n \\end{markdown}'
pl.tex.help_wrt(val, md)
@@ -109,7 +105,6 @@ end
-
-- xfm functions (transforms) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
function YAMLvars.xfm.addxspace(var, val)
return val .. '\\xspace'
@@ -124,7 +119,7 @@ function YAMLvars.xfm.arrsort2ZA(var, val)
end
function YAMLvars.xfm.addrule2arr(var, val)
- return pl.array2d.map_slice2(_1..'\\\\\\'.. YAMLvars.tabmidrule..' ', val, 1,-1,-2,-1)
+ return pl.array2d.map_slice2(_1..'\\\\\\'.. YAMLvars.setts.tabmidrule..' ', val, 1,-1,-2,-1)
end
function YAMLvars.xfm.arr2tabular(var, val)
@@ -296,19 +291,13 @@ end
-- --
--- ??
---token.set_macro('yv--'..var, val, 'global') -- todo fix with csname hack?
-
-
-
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
function YAMLvars.makecmd(cs, val) -- provide command via lua
- if token.is_defined(cs) and (not YAMLvars.overwritedefs) then
+ if token.is_defined(cs) and (not YAMLvars.setts.overwrite) then
YAMLvars.pkgerr('Variable '..cs..' already defined, could not declare')
else
pl.tex.defcmd(cs, val)
- --token.set_macro(cs, val, 'global') -- issues if val contains undefined macro
end
end
@@ -334,15 +323,18 @@ local function getYAMLfile(y)
end
end
+local function default_stuff()
+ return {xfm=YAMLvars.setts.xfm,prc=YAMLvars.setts.prc,dft=YAMLvars.setts.dft}
+end
function YAMLvars.declareYAMLvarsStr(y)
local t = YAMLvars.yaml.parse(y)
for var, specs in pairs(t) do
- if pl.hasval(specs['lowcasevar']) or YAMLvars.lowvasevarall then
+ if pl.hasval(specs['lowcasevar']) or YAMLvars.setts.lowercase then
var = var:lower()
YAMLvars.varslowcase:append(var)
end
- YAMLvars.varspecs[var] = {xfm=YAMLvars.xfmDefault,prc=YAMLvars.prcDefault,dft=YAMLvars.dftDefault}
+ YAMLvars.varspecs[var] = default_stuff()
if type(specs) == 'string' then
specs = {xfm={specs}}
end
@@ -353,8 +345,6 @@ function YAMLvars.declareYAMLvarsStr(y)
end
if YAMLvars.dec[YAMLvars.varspecs[var].prc] ~= nil then
YAMLvars.dec[YAMLvars.varspecs[var].prc](var, YAMLvars.varspecs[var].dft)
- --else -- actually don't a dec function for all
- -- -- -- -- tex.print('\\PackageError{YAMLvars}{Declaration function for '..YAMLvarspecs[var].prc..'not found}{}')
end
end
YAMLvars.debugtalk(YAMLvars.varspecs, 'declared YAML vars, varspecs')
@@ -367,21 +357,6 @@ function YAMLvars.declareYAMLvarsFile(y)
end
-local function check_def(var, val)
- if YAMLvars.allowUndeclared then
- if YAMLvars.prcDefault == 'yvdef' then
- YAMLvars.prc.yvdef(var, val)
- YAMLvars.debugtalk(var..' = '..val,'yvdef made (undeclared)')
- else
- YAMLvars.makecmd(var, val)
- YAMLvars.debugtalk(var..' = '..val,'gdef made (undeclared)')
- end
- else
- --tex.print('\\PackageError{YAMLvars}{Variable "'..var..'" set but not declared}{}')
- YAMLvars.pkgerr('Variable "'..var..'" set but not declared')
- end
-end
-
local function sub_lua_var(s, v1, v2)
return s:gsub('([%A?%-?])('..v1..')([%W?%-?])', '%1'..v2..'%3') -- replace x variables
end
@@ -399,15 +374,11 @@ local function eval_expr(func, var, val)
if c == 0 then
return _YV_invalid_expression
else
- --pl.tex.help_wrt(s, var)
- --pl.tex.help_wrt(val, var)
YAMLvars.valTemp = val
YAMLvars.varTemp = var
- --pl.tex.help_wrt(s, var)
s, c = s:gsub('\2', '') -- strip \2 that might have appeared if / was applied
s = sub_lua_var(' '..s, 'x', 'YAMLvars.valTemp')
s = sub_lua_var(s, 'v', 'YAMLvars.varTemp')
- --pl.tex.help_wrt(s, var)
local f, err = pcall(loadstring(s))
if not f then
--tex.print('\\PackageError{YAMLvars}{xfm with "= or /" error on var "'..var..'"}{}') --
@@ -439,24 +410,24 @@ local function transform_and_prc(var, val)
end
f = YAMLvars.prc[YAMLvars.varspecs[var]['prc']]
if f == nil then
- --tex.print('\\PackageError{YAMLvars}{prc function "'..YAMLvars.varspecs[var]['prc']..'" on var "'..var..'" not defined}{}')
YAMLvars.pkgerr('prc function "'..YAMLvars.varspecs[var]['prc']..'" on var "'..var..'" not defined')
end
f(var, val) -- prc the value of the variable
end
+
+
function YAMLvars.parseYAMLvarsStr(y)
YAMLvars.varsvals = YAMLvars.yaml.parse(y)
for var, val in pairs(YAMLvars.varsvals) do
if YAMLvars.varslowcase:contains(var:lower()) then
var = var:lower()
end
- if YAMLvars.varspecs[var] == nil then
- check_def(var, val) -- if not declared
- -- todo consider free form parse declaring
- -- variable name: {xfm:, dec:, prc:, val: }
- -- definitely doable here
- else
+ if YAMLvars.varspecs[var] == nil and YAMLvars.setts.undeclared then
+ YAMLvars.debugtalk(YAMLvars.setts, 'XYZ')
+ YAMLvars.varspecs[var] = default_stuff() -- if undeclared and allowing, add to varspec set to default xfm, prc, dft
+ end
+ if YAMLvars.varspecs[var] ~= nil then -- if specified, process
transform_and_prc(var, val)
end
end
@@ -501,7 +472,6 @@ function YAMLvars.getYAMLcli()
end
end
end
- --pl.tex.help_wrt(t)
return t
end
@@ -572,71 +542,8 @@ function YAMLvars.prc.memoFr(var, val)
end
end
--- produce \Var[val[2]\\val[3].....\val[n]]{val[1]}
---function YAMLvars.prc.setdocvarOpt(var, val)
--- if type(val) ~= 'table' then
--- val = {val}
--- end
--- local s = '\\'..var..'{'..tostring(val[1])..'}'
--- s = s..'['..pl.List(v):map_slice1():join()..']' -- what does this do?
--- tex.print(s)
---end
---
---
---function YAMLvars.prc.setdocvarOpts(var, val)
--- if type(val) ~= 'table' then
--- val = {val}
--- end
--- local s = '\\'..var..'{'..tostring(val[1])..'}'
--- for k, v in pairs(val) do
--- if k > 1 then
--- s = s..'['..tostring(v)..']'
--- end
--- end
--- tex.print(s)
---end
-
-return YAMLvars
-
-
-
-
-
-
- --token.set_macro('@memoFr', k, 'global')
- --token.set_macro('@memoFrAddr', v, 'global')
- --token.set_macro('@memoTo', k, 'global')
- --token.set_macro('@memoToAddr', v, 'global')
- --help_wrt(var,val)
- -- token.set_macro('@'..var, val, 'global')
-
---function YAMLvars.prc.title(var, val)
--- YAMLvars.prc.setdocvar('title', val)
---end
---
---
---function YAMLvars.prc.author(var, val)
--- YAMLvars.prc.setdocvar('author', val)
---end
---
---function YAMLvars.prc.date(var, val)
--- YAMLvars.prc.setdocvar('date', val)
---end
-
-
- --clean = clean or true
- --if clean then -- clean first part of yaml string
- -- y = clean_tex_spaces(y)
- --end
---local function clean_tex_spaces(s)
--- pl.tex.help_wrt(s)
--- if s:sub(1,2) == '%s' then
--- s, _ = s:gsub('%s+','',1)
--- end
--- s, _ = s:gsub('\\par ','\n\n')
--- return s
---end
+return YAMLvars
diff --git a/macros/luatex/latex/yamlvars/yamlvars.pdf b/macros/luatex/latex/yamlvars/yamlvars.pdf
index 093dbecd8c..a91095c832 100644
--- a/macros/luatex/latex/yamlvars/yamlvars.pdf
+++ b/macros/luatex/latex/yamlvars/yamlvars.pdf
Binary files differ
diff --git a/macros/luatex/latex/yamlvars/yamlvars.sty b/macros/luatex/latex/yamlvars/yamlvars.sty
index b04e7d306f..20ea6d33d1 100644
--- a/macros/luatex/latex/yamlvars/yamlvars.sty
+++ b/macros/luatex/latex/yamlvars/yamlvars.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2022-11-06
+% 2023-07-18
% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -25,60 +25,94 @@
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{yamlvars}[2022-11-06]
-
-\IfFileExists{markdown-tinyyaml.lua}{}{\PackageError{YAMLvars}{This package requires installation of the 'markdown' package, please install it and try again}{}}
+\ProvidesPackage{yamlvars}[2023-07-18]
\RequirePackage{luacode}
\RequirePackage{xspace}
\RequirePackage{etoolbox}
+\RequirePackage{luakeys}
\RequirePackage{penlight} % no option passed here, but extras must be used, error will be thrown if not
+%\IfFileExists{tinyyaml.lua}{}{\PackageError{yamlvars}{This package requires installation of the 'tinyyaml' package, please install it and try again}{}}
+
+
\luadirect{YAMLvars = require('YAMLvars')}
\DeclareOption{useyv}{
\gdef\yv#1{\csname yv--#1\endcsname}
- \luadirect{YAMLvars.prcDefault = 'yvdef'}
+ \luadirect{YAMLvars.setts.prc = 'yvdef'}
+ \luadirect{YAMLvars.settsdefault.prc = 'yvdef'}
}
\DeclareOption{parseCLI}{
\AtBeginDocument{\luadirect{YAMLvars.doYAMLfiles(YAMLvars.getYAMLcli())}}
}
+\DeclareOption{debug}{
+ \luadirect{YAMLvars.debug = true}
+}
+
+
+
+
+
+
+
+
+
+
+%% todo delete below
+\newcommand{\lowercasevarYVon}{\luadirect{YAMLvars.lowvasevarall = true}}
+\newcommand{\lowercasevarYVoff}{\luadirect{YAMLvars.lowvasevarall = false}}
+\newcommand{\AllowUndeclaredYV}{\luadirect{YAMLvars.setts.undeclared = true}}
+\newcommand{\ForbidUndeclaredYV}{\luadirect{YAMLvars.setts.undeclared = false}}
+\newcommand{\TextualYV}{\luadirect{
+YAMLvars.allowUndeclared = true
+YAMLvars.xfmDefault = {'lb2nl','addxspace'}
+}}
\DeclareOption{allowundeclared}{
- \luadirect{YAMLvars.allowUndeclared = true}
+ \luadirect{YAMLvars.settsdefault.undeclared = true}
}
\DeclareOption{overwritedefs}{
- \luadirect{YAMLvars.overwritedefs = true}
-}
-\DeclareOption{debug}{
- \luadirect{YAMLvars.debug = true}
+ \luadirect{YAMLvars.settsdefault.overwrite = true}
}
+%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+
+
-\newcommand{\AllowUndeclaredYV}{\luadirect{YAMLvars.allowUndeclared = true}}
-\newcommand{\ForbidUndeclaredYV}{\luadirect{YAMLvars.allowUndeclared = false}}
\DeclareOption*{\PackageWarning{YAMLvars}{Unknown option: '\CurrentOption'}{}}
\ProcessOptions\relax
+\luadirect{YAMLvars.setts2default()}
+
\newcommand{\declareYAMLvarsFile}[1]{\luadirect{YAMLvars.declareYAMLvarsFile(\luastring{#1})}}
-\newcommand{\parseYAMLvarsFile}[1]{\luadirect{YAMLvars.parseYAMLvarsFile(\luastring{#1})}}
+\NewDocumentCommand{\parseYAMLvarsFile}{m}{\luadirect{
+ YAMLvars.parseYAMLvarsFile(\luastring{#1})
+}}
\newenvironment{declareYAMLvars}{\luadirect{_G[__PENLIGHT__].tex.startrecording()}}{\luadirect{_G[__PENLIGHT__].tex.stoprecording()}
\luadirect{YAMLvars.declareYAMLvarsStr(_G[__PENLIGHT__].tex.recordedbuf)}
}
-\newenvironment{parseYAMLvars}{\luadirect{_G[__PENLIGHT__].tex.startrecording()}}{\luadirect{_G[__PENLIGHT__].tex.stoprecording()}
-}
+
+\NewDocumentEnvironment{parseYAMLvars}{}%
+{\luadirect{
+ _G[__PENLIGHT__].tex.startrecording()
+}}%
+{\luadirect{
+ _G[__PENLIGHT__].tex.stoprecording()
+}}
\AfterEndEnvironment{parseYAMLvars}{\luadirect{YAMLvars.parseYAMLvarsStr(_G[__PENLIGHT__].tex.recordedbuf)}}
% necessary hack to get rohead and lohead to work..
% .. https://tex.stackexchange.com/questions/637018/setting-koma-heading-within-lua/637021?noredirect=1#comment1587387_637021
-\newcommand{\resetYAMLvarsspec}{\luadirect{YAMLvars.varspec = {}}}
-\newcommand{\lowercasevarYVon}{\luadirect{YAMLvars.lowvasevarall = true}}
-\newcommand{\lowercasevarYVoff}{\luadirect{YAMLvars.lowvasevarall = false}}
+\newcommand{\resetYAMLvarsspec}{\luadirect{YAMLvars.varspec = {}}}
@@ -89,3 +123,18 @@
}
}
+
+
+
+\NewDocumentCommand{\setYAMLvars}{s m }{\luadirect{
+ YAMLvars.updatesettskv(\luastring{#2}, \luastring{#1})
+}}
+
+\NewDocumentCommand{\setdefYAMLvars}{ m }{\luadirect{
+ YAMLvars.updatesettskv(pl.tex._xFalse, \luastring{#1}, true)
+}}
+
+% \IfBooleanTF{#1}{\luadirect{YAMLvars.setts = pl.tablex.deepcopy(YAMLvars.settsdefault)}}{} % if * return to default first
+% \luadirect{pl.tablex.update(YAMLvars.setts, luakeys.parse(\luastring{#2}))}
+% \luadirect{YAMLvars.setts.xfm = {'lb2nl', 'addxspace'}}
+
diff --git a/macros/luatex/latex/yamlvars/yamlvars.tex b/macros/luatex/latex/yamlvars/yamlvars.tex
index 5290f9ec88..cd6888cea8 100644
--- a/macros/luatex/latex/yamlvars/yamlvars.tex
+++ b/macros/luatex/latex/yamlvars/yamlvars.tex
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2022-11-06
+% 2023-07-18
% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -53,8 +53,8 @@
\date{\today}
-\usepackage[pl,extrasnoglobals]{penlight}
-\usepackage[overwritedefs]{YAMLvars}
+\usepackage[pl,extrasglobals]{penlight}
+\usepackage[overwritedefs]{yamlvars}
\title{YAMLvars}
\subtitle{a YAML variable parser for LuaLaTeX}
@@ -107,14 +107,10 @@ will br thrown if the name exists. Alternatively, you can use the commands \cmd{
\llcmd{overwritedefs}Danger! This will allow you to \cmd{gdef} commands with YAML. Caution should be taken to not set definitions like \cmd{begin}, \cmd{section}, etc.
\section{Dependencies}
-%This package contains the \texttt{tinyyaml} Lua package.
-\llcmd{Note:}This package requires that the \cmd{markdown} (\url{https://ctan.org/pkg/markdown}) be installed. This package does not use the package in its entirety, but rather depends on the YAML interpreter it comes with: \cmd{markdown-tinyyaml.lua}. This dependency is chosen to avoid redundancy in your TeX installation and align development of the \cmd{tinyyaml} Lua package.
-If you want to use the YAML interpreter for other purposes, you can bring it into Lua by either:
-\begin{verbatim}
-\directlua{yaml = YAMLvars.yaml} or
-\directlua{yaml = require'markdown-tinyyaml'}
-\end{verbatim}
+\llcmd{Note:}This package requires the \cmd{tinyyaml} package, available on CTAN.
+
The distribution: \url{https://github.com/api7/lua-tinyyaml}\\
+\ \ \ \ \url{https://ctan.org/pkg/lua-tinyyaml}\\
The YAML specification: \url{https://yaml.org/spec/}\\
Many of the ``transform'' and ``processing'' functions built-in to this package rely on other packages,
@@ -393,5 +389,32 @@ Items:
\lstinputlisting[linerange=113-296]{yamlvars.lua}
+%
+%\AllowUndeclaredYV
+%\luadirect{YAMLvars.xfmDefault={'lb2nl','addxspace'}}
+
+%
+%\luadirect{YAMLvars.debug = true}
+%\setYAMLvars{undeclared, xfm= lb2nl addxspace}
+%\begin{parseYAMLvars}
+%kale: |-
+% kale
+% eee
+%\end{parseYAMLvars}
+%
+%\kale ee
+%
+%\setYAMLvars{undeclared, xfm=list2items}
+%\begin{parseYAMLvars}
+%lllist:
+% - one
+% - two
+% - three
+%\end{parseYAMLvars}
+%
+%\begin{itemize}
+% \lllist
+%\end{itemize}
+
\end{document}