summaryrefslogtreecommitdiff
path: root/macros/luatex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-11-27 03:00:55 +0000
committerNorbert Preining <norbert@preining.info>2023-11-27 03:00:55 +0000
commitc053caa3ee50538ec23a08c0d35a0ca205b9923d (patch)
tree32e5dc4189b700e7aad1c6515f68933a77a30be4 /macros/luatex
parent0d14ad8d416e14dc61b009c524689462ace354d5 (diff)
CTAN sync 202311270300
Diffstat (limited to 'macros/luatex')
-rw-r--r--macros/luatex/generic/penlightplus/penlightplus.lua19
-rw-r--r--macros/luatex/generic/penlightplus/penlightplus.pdfbin63923 -> 65123 bytes
-rw-r--r--macros/luatex/generic/penlightplus/penlightplus.sty56
-rw-r--r--macros/luatex/generic/penlightplus/penlightplus.tex85
-rw-r--r--macros/luatex/latex/yamlvars/yamlvars.lua27
-rw-r--r--macros/luatex/latex/yamlvars/yamlvars.pdfbin82984 -> 83795 bytes
-rw-r--r--macros/luatex/latex/yamlvars/yamlvars.sty15
-rw-r--r--macros/luatex/latex/yamlvars/yamlvars.tex35
8 files changed, 165 insertions, 72 deletions
diff --git a/macros/luatex/generic/penlightplus/penlightplus.lua b/macros/luatex/generic/penlightplus/penlightplus.lua
index 1f74d45777..84cd2094ff 100644
--- a/macros/luatex/generic/penlightplus/penlightplus.lua
+++ b/macros/luatex/generic/penlightplus/penlightplus.lua
@@ -1,5 +1,5 @@
--% Kale Ewasiuk (kalekje@gmail.com)
---% 2023-09-04
+--% 2023-11-25
--% Copyright (C) 2021-2023 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -449,6 +449,10 @@ function str_mt.__index.trimfl(str)
return str:sub(2,-2)
end
+function str_mt.__index.subpar(s, r)
+ r = r or ' '
+ return (s:gsub('\\par', r))
+end
-- -- -- -- function stuff
@@ -802,6 +806,7 @@ function penlight.get_tbl_index(s)
return tbl, key
end
+
function penlight.get_tbl_item(s, p) -- get item with string, p means print value
p = p or false
local tbl, key = penlight.get_tbl_index(s)
@@ -840,6 +845,18 @@ function penlight.check_recent_tbl_undefault()
end
+penlight.tbl_xysep = '%s+' -- spaces separate x-y coords
+function penlight.def_tbl_coords(str, def)
+ -- todo could definitely make this flexible for a table...
+ local x, y = str:strip():splitv(penlight.tbl_xysep)
+ --if (~penlight.hasval(x)) or (~penlight.hasval(y)) then
+ -- penlight.tex.pkgerror('penlightplus', 'def_tbl_coords function could not parse coordiantes given as "'..str..'" ensure two numbers separated by space are given!', '', true)
+ --end
+ token.set_macro(def..'x', tostring(x))
+ token.set_macro(def..'y', tostring(y))
+end
+
+
if penlight.hasval(__PL_GLOBALS__) then
-- iterators
kpairs = penlight.utils.kpairs
diff --git a/macros/luatex/generic/penlightplus/penlightplus.pdf b/macros/luatex/generic/penlightplus/penlightplus.pdf
index 0f35dbf75a..7e273cb6c1 100644
--- a/macros/luatex/generic/penlightplus/penlightplus.pdf
+++ b/macros/luatex/generic/penlightplus/penlightplus.pdf
Binary files differ
diff --git a/macros/luatex/generic/penlightplus/penlightplus.sty b/macros/luatex/generic/penlightplus/penlightplus.sty
index 01b0aafc16..97083c6bff 100644
--- a/macros/luatex/generic/penlightplus/penlightplus.sty
+++ b/macros/luatex/generic/penlightplus/penlightplus.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2023-09-04
+% 2023-11-25
% Copyright (C) 2021-2023 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}[2023-09-04]
+\ProvidesPackage{penlightplus}[2023-11-25]
\RequirePackage{luacode}
\RequirePackage{luakeys}
@@ -62,12 +62,12 @@
\luadirect{penlight.tex.aliasluastring(\luastring{#2},\luastring{#1})}%
}
-\NewDocumentCommand{\splitToComma}{ O{nn} m m }{%
+\NewDocumentCommand{\splittocomma}{ O{nn} m m }{%
\MakeluastringCommands[nn]{#1}%
\luadirect{penlight.tex.split2comma(\plluastringA{#2},\plluastringB{#3})}%
}
-\NewDocumentCommand{\splitToItems}{ O{NN} m m }{%
+\NewDocumentCommand{\splittoitems}{ O{NN} m m }{%
\MakeluastringCommands[nn]{#1}%
\luadirect{penlight.tex.split2items(\plluastringA{#2},\plluastringB{#3})}%
}
@@ -103,45 +103,67 @@
-%%%
+%%% tbls below
-\NewDocumentCommand{\newtbl}{m}{\luadirect{
+\NewDocumentCommand{\tblnew}{m}{\luadirect{% initialize a tbl
penlight.tbls[\luastring{#1}] = {}
penlight.rec_tbl = \luastring{#1}
}}
-\NewDocumentCommand{\tblfrkv}{m m O{}}{ \luadirect{
+\NewDocumentCommand{\tblfrkv}{m +m O{}}{\luadirect{%
penlight.rec_tbl_opts = penlight.luakeys.parse(\luastring{#3})
- penlight.tbls[\luastring{#1}] = penlight.luakeys.parse(\luastring{#2}, penlight.rec_tbl_opts)
+ penlight.wrth(\luastring{#2}, '??')
+ penlight.tbls[\luastring{#1}] = penlight.luakeys.parse(string.subpar(\luastring{#2}), penlight.rec_tbl_opts)
penlight.rec_tbl = \luastring{#1}
}}
-\NewDocumentCommand{\tblfrcsv}{m m O{}}{\tblfrkv{#1}{#2}[naked_as_value=true,#3]}
+\NewDocumentCommand{\tblfrkvN}{m +m O{}}{\luadirect{%
+ penlight.rec_tbl_opts = penlight.luakeys.parse(\luastring{#3})
+ penlight.tbls[\luastring{#1}] = penlight.luakeys.parse(string.subpar(\luastringN{#2}), penlight.rec_tbl_opts)
+ penlight.rec_tbl = \luastring{#1}
+}}
+
+\NewDocumentCommand{\tblfrcsv}{m +m O{}}{\tblfrkv{#1}{#2}[naked_as_value=true,#3]}
-\NewDocumentCommand{\kvtblundefcheck}{}{\luadirect{penlight.check_recent_tbl_undefault()}} % todo
+\NewDocumentCommand{\tblkvundefcheck}{}{\luadirect{penlight.check_recent_tbl_undefault()}}% check defaults list and throw error if foreign keys were used
-\NewDocumentCommand{\chgtbl}{ m }{ \luadirect{
+\NewDocumentCommand{\tblchg}{ m }{\luadirect{% change recent table
penlight.rec_tbl = \luastring{#1}
}}
-\NewDocumentCommand{\gettbl}{m}{\luadirect{
+
+\NewDocumentCommand{\tblget}{m}{\luadirect{% get an item
penlight.get_tbl_item(\luastring{#1}, true)
}}
-\NewDocumentCommand{\settbl}{m m}{\luadirect{
+\NewDocumentCommand{\tblset}{m m}{\luadirect{% set item with {value}
penlight.set_tbl_item(\luastring{#1}, \luastring{#2})
}}
-\NewDocumentCommand{\deftbl}{ m m }{\luadirect{% define a table, use * to make definition
+\NewDocumentCommand{\tbldef}{ m m }{\luadirect{% define a table, use * to make definition
token.set_macro(\luastring{#2}, tostring(penlight.get_tbl_item(\luastring{#1})))
}}
-\NewDocumentCommand{\gdeftbl}{ m m }{\luadirect{% define a table, use * to make global definition
+\NewDocumentCommand{\tblgdef}{ m m }{\luadirect{% define a table, use * to make global definition
token.set_macro(\luastring{#2}, tostring(penlight.get_tbl_item(\luastring{#1})), 'global')
}}
-\NewDocumentCommand{\iftbl}{m m O{}}{\ifluax{penlight.get_tbl_item(\luastring{#1})}{#2}[#3]}
+\NewDocumentCommand{\tbldefxy}{ m m }{\luadirect{penlight.def_tbl_coords(penlight.get_tbl_item(\luastring{#1}), \luastring{#2})}}% define #2x and #2y from a space delimited x-y pair
+
+
+\NewDocumentCommand{\tblif}{m m O{}}{\ifluax{penlight.get_tbl_item(\luastring{#1})}{#2}[#3]}
+
+\NewDocumentCommand{\tblifv}{m m O{}}{\ifluaxv{penlight.get_tbl_item(\luastring{#1})}{#2}[#3]}
-\NewDocumentCommand{\iftblv}{m m O{}}{\ifluaxv{penlight.get_tbl_item(\luastring{#1})}{#2}[#3]}
+% legacy code, delete this
+\let\kvtblundefcheck\tblkvundefcheck
+\let\chgtbl\tblchg
+\let\newtbl\tblnew
+\let\gettbl\tblget
+\let\settbl\tblset
+\let\deftbl\tbldef
+\let\gdeftbl\tblgdef
+\let\iftbl\tblif
+\let\iftblv\tblifv \ No newline at end of file
diff --git a/macros/luatex/generic/penlightplus/penlightplus.tex b/macros/luatex/generic/penlightplus/penlightplus.tex
index fbc4ec32d5..169364847c 100644
--- a/macros/luatex/generic/penlightplus/penlightplus.tex
+++ b/macros/luatex/generic/penlightplus/penlightplus.tex
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2023-09-04
+% 2023-11-25
% Copyright (C) 2021-2023 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -157,7 +157,7 @@ The user can specify \cmd{n}, \cmd{o}, \cmd{t}, and \cmd{f} (case insensitve) if
no, once, twice, or full expansion. For example, we can control the expansion of args 2 and 3 with arg 1:
\begin{verbatim}
- \NewDocumentCommand{\splitToComma}{ O{nn} m m }{%
+ \NewDocumentCommand{\splittocomma}{ O{nn} m m }{%
\MakeluastringCommands[nn]{#1}%
\luadirect{penlight.tex.split2comma(\plluastringA{#2},\plluastringB{#3})}%
}
@@ -199,17 +199,19 @@ no, once, twice, or full expansion. For example, we can control the expansion of
\cmd{penlight.tbls} table.
-\cmd{\newtbl{t}} declares a new table with name \cmd{t}\\
-\cmd{\chgtbl{t}} changes the 'recent' table\\
+\cmd{\tblnew{t}} declares a new table with name \cmd{t}\\
+\cmd{\tblchg{t}} changes the 'recent' table\\
\cmd{\tblfrkv{t}{key-val string}[luakeys opts]} new table from key-vals using \cmd{luakeys} \\
+\cmd{\tblfrkvN{t}{key-val string}[luakeys opts]} does not expand key-val string \cmd{luakeys} \\
\cmd{\tblfrcsv} a shorthand \cmd{\tblfrkv{t}{csv}[naked_as_value=true,opts]}, a good way to convert a comma-separated list to an array\\
-\cmd{\settbl{i}{v}} sets a value of the table/index \cmd{i} to \cmd{v}\\
-\cmd{\gettbl{i}} gets the value and \cmd{tex.sprint()}'s it\\
-\cmd{\deftbl{i}{d}} pushes the value to a \cmd{cs} named \cmd{d}\\
-\cmd{\gdeftbl{i}{d}} pushes the value to a global\\
+\cmd{\tblset{i}{v}} sets a value of the table/index \cmd{i} to \cmd{v}\\
+\cmd{\tblget{i}} gets the value and \cmd{tex.sprint()}'s it\\
+\cmd{\tbldef{i}{d}} pushes the value to a \cmd{cs} named \cmd{d}\\
+\cmd{\tblgdef{i}{d}} pushes the value to a global\\
+\cmd{\tbldefxy{i}{d}} splits the value of item by spaces creates two definitions \cmd{\dx} and \cmd{\dy}. Useful for pasing tikz coordinates like \cmd{xy=0 5}\\
\cmd{\iftbl{i}{tr}[fa]} runs code \cmd{ta} if the item is true else \cmd{fr}\\
\cmd{\iftblv{i}{tr}[fa]} runs code \cmd{ta} if the item is truthy else \cmd{fr}\\
-\cmd{\kvtblundefcheck} will throw an error if you use define a table from key-values
+\cmd{\tblkvundefcheck} will throw an error if you use define a table from key-values
and use a key that was not specified in the luakeys parse options via \cmd{opts.defaults} or \cmd{opts.defs}.
There are 3 ways to use the index (placeholder \cmd{{i}} above).
@@ -220,53 +222,68 @@ or simply use \cmd{ind} without the table name, where the assumed table is the l
\begin{LTXexample}[width=0.3\linewidth]
\tblfrkv{my}{a,b,c,first=john,last=smith}%
[defaults={x=0,1=one,n=false,y=yes}]
-\gettbl{my.a}\\
-\gettbl{my.x}\\
-\iftbl{n}{tr}[fa]\\
-\iftblv{n}{TR}[FA]\\
-\iftbl{my.y}{Tr}[Fa]\\
-\iftblv{y}{tR}[fA]\\
+\tblget{my.a}\\
+\tblset{a}{tRuE!!}
+\tblget{a}\\
+\tblget{my.x}\\
+\tblif{n}{tr}[fa]\\
+\tblifv{n}{TR}[FA]\\
+\tblif{my.y}{Tr}[Fa]\\
+\tblifv{y}{tR}[fA]\\
%% \kvtblundefcheck % would throw error
-\deftbl{my.first}{mydef} \mydef\\
-{\deftbl{last}{mydef} \mydef} \mydef\\
-{\gdeftbl{last}{mydef}} \mydef\\
+\tbldef{my.first}{mydef} \mydef\\
+{\tbldef{last}{mydef} \mydef} \mydef\\
+{\tblgdef{last}{mydef}} \mydef\\
+
+\tblset{my.a}{12 36}
+\tbldefxy{my.a}{coord} (\coordx,\coordy)
\tblfrcsv{me}{a,b,"c,see",d,e}
-\gettbl{me/1},\gettbl{2}\\
-\gettbl{3}\\
-\settbl{me/4}{D}\gettbl{me/4}\\
-\settbl{5}{E}\gettbl{5}\\
-\gettbl{-2},\gettbl{me/-1}\\
-%% \gettbl{k} % would throw error
+\tblget{me/1},\tblget{2}\\
+\tblget{3}\\
+\tblset{me/4}{D}\tblget{me/4}\\
+\tblset{5}{E}\tblget{5}\\
+\tblget{-2},\tblget{me/-1}\\
+%% \tblget{k} % would throw error
\end{LTXexample}
+\tblfrcsv{me}{
+Hello=world,
+
+
+Bonjour=terre,
+}
+\tblget{Hello}
+\tblget{Bonjour}
+Note: for thisf versions: all latex tbl commands are now prefixed with \cmd{tbl}, eg., \cmd{tblget}, \cmd{tblset}.
+Old-style commands eg. \cmd{gettbl} will be kept as aliases for a few more releases then removed.
\subsection*{Splitting strings}
Splitting text (or a cmd) into oxford comma format via:
-\cmd{\splitToComma[expansion level]{text}{text to split on}}:
+\cmd{\splittocomma[expansion level]{text}{text to split on}}:
\begin{LTXexample}[width=0.3\linewidth]
--\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}-
+-\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}
+\splittocomma[o]{\authors}{\and}
\end{LTXexample}
The expansion level is up to two characters, \cmd{n|o|t|f}, to control the expansion of each argument.
-You can do a similar string split but to \cmd{\item} instead of commas with \cmd{\splitToItems}
+You can do a similar string split but to \cmd{\item} instead of commas with \cmd{\splittoitems}
\begin{LTXexample}
\begin{itemize}
- \splitToItems{kale\and john}{\and}
- \splitToItems{kale -john -someone else}{-}
- \splitToItems{1,2,3,4}{,}
+ \splittoitems{kale\and john}{\and}
+ \splittoitems{kale -john -someone else}{-}
+ \splittoitems{1,2,3,4}{,}
\end{itemize}
\end{LTXexample}
diff --git a/macros/luatex/latex/yamlvars/yamlvars.lua b/macros/luatex/latex/yamlvars/yamlvars.lua
index 479880a3e8..d6d2f7ca4f 100644
--- a/macros/luatex/latex/yamlvars/yamlvars.lua
+++ b/macros/luatex/latex/yamlvars/yamlvars.lua
@@ -1,5 +1,5 @@
--% Kale Ewasiuk (kalekje@gmail.com)
---% 2023-07-22
+--% 2023-11-25
--% Copyright (C) 2021-2023 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -48,11 +48,15 @@ YAMLvars.varTemp = ''
YAMLvars.debug = false
+
YAMLvars.setts = {}
+YAMLvars.setts.parseopts = {timestamps=false}
+YAMLvars.setts.decstr = 'xfm' -- if in declaration key, value is a string, how should it be treated
YAMLvars.setts.undeclared = false
YAMLvars.setts.overwrite = false
YAMLvars.setts.lowercase = false
YAMLvars.setts.tabmidrule = 'midrule'
+YAMLvars.setts.prcstring = true
YAMLvars.setts.xfm = {}
YAMLvars.setts.prc = 'gdef'
YAMLvars.setts.dft = ''
@@ -325,7 +329,7 @@ local function default_stuff()
end
function YAMLvars.declareYAMLvarsStr(y)
- local t = YAMLvars.yaml.parse(y)
+ local t = YAMLvars.yaml.parse(y, YAMLvars.setts.parseopts)
for var, specs in pairs(t) do
if pl.hasval(specs['lowcasevar']) or YAMLvars.setts.lowercase then
var = var:lower()
@@ -333,9 +337,11 @@ function YAMLvars.declareYAMLvarsStr(y)
end
YAMLvars.varspecs[var] = default_stuff()
if type(specs) == 'string' then
- specs = {xfm={specs}}
+ if YAMLvars.setts.decstr == 'xfm' then specs = {xfm={specs}} end
+ if YAMLvars.setts.decstr == 'dft' then specs = {dft=specs} end
+ if YAMLvars.setts.decstr == 'prc' then specs = {prc=specs} end
end
- if specs['xfm'] == nil then specs['xfm'] = {} end
+ if specs['xfm'] == nil then specs['xfm'] = YAMLvars.setts.xfm end
for s, p in pairs(specs) do
if s == 'xfm' and type(p) ~= 'table' then p = {p} end
YAMLvars.varspecs[var][s] = p -- set property of var
@@ -402,6 +408,8 @@ local function transform_and_prc(var, val)
val = val2
end
else
+ YAMLvars.debugtalk('function: '..func..'\nvariable: '.. var .. '\n' ..
+ 'value: '.. tostring(val) .. '\nval type: ' ..type(val), "Applying transforming (xfm) function")
val = f(var, val)
end
end
@@ -409,13 +417,20 @@ local function transform_and_prc(var, val)
if f == nil then
YAMLvars.pkgerr('prc function "'..YAMLvars.varspecs[var]['prc']..'" on var "'..var..'" not defined')
end
+ YAMLvars.debugtalk('function: '..YAMLvars.varspecs[var]['prc']..'\nvariable: '.. var .. '\n' ..
+ 'value: '.. tostring(val) .. '\nval type: ' ..type(val), "Applying processing (prc) function")
+
+ if YAMLvars.setts.prcstring then
+ val = tostring(val)
+ end
f(var, val) -- prc the value of the variable
end
function YAMLvars.parseYAMLvarsStr(y)
- YAMLvars.varsvals = YAMLvars.yaml.parse(y)
+ YAMLvars.debugtalk(YAMLvars.varsvals, 'Parsing YAML vars with table')
+ YAMLvars.varsvals = YAMLvars.yaml.parse(y, YAMLvars.setts.parseopts)
for var, val in pairs(YAMLvars.varsvals) do
if YAMLvars.varslowcase:contains(var:lower()) then
var = var:lower()
@@ -477,7 +492,7 @@ function YAMLvars.getYAMLcli()
YAMLvars.yaml2PDFmetadata = function(ytext) -- parse a YAML file and update the pdfmetadata table
__PDFmetadata__ = __PDFmetadata__ or {} -- existing metadata
if ytext ~= nil then
- local pdfmetadata_yaml = YAMLvars.yaml.parse(ytext) -- new metadata
+ local pdfmetadata_yaml = YAMLvars.yaml.parse(ytext, {timestamps = false}) -- new metadata
local t = {}
for k,v in pairs(pdfmetadata_yaml) do -- ensure first character is capital letter
t[k:upfirst()] = v
diff --git a/macros/luatex/latex/yamlvars/yamlvars.pdf b/macros/luatex/latex/yamlvars/yamlvars.pdf
index 4719837d3c..013335b3ad 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 733ee80b69..bd0643ec57 100644
--- a/macros/luatex/latex/yamlvars/yamlvars.sty
+++ b/macros/luatex/latex/yamlvars/yamlvars.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2023-07-22
+% 2023-11-25
% Copyright (C) 2021-2023 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -25,7 +25,7 @@
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{yamlvars}[2023-07-22]
+\ProvidesPackage{yamlvars}[2023-11-25]
\RequirePackage{luacode}
\RequirePackage{etoolbox}
@@ -38,7 +38,9 @@
\luadirect{YAMLvars = require('YAMLvars')}
\DeclareOption{useyv}{
- \gdef\yv#1{\csname yv--#1\endcsname}
+ \newcommand\yv{}
+ \gdef\yv#1{\csname yv--#1\endcsname} % todo not working... why??
+% \NewDocumentCommand{\yv}{m}{\luadirect{tex.sprint(tostring(token.get_macro('yv--'..\luastring{#1})))}}
\luadirect{YAMLvars.setts.prc = 'yvdef'}
\luadirect{YAMLvars.settsdefault.prc = 'yvdef'}
}
@@ -58,7 +60,8 @@
-%% todo delete below
+\newcommand{\yamlvarsdebugon}{\luadirect{YAMLvars.debug = true}}
+\newcommand{\yamlvarsdebugoff}{\luadirect{YAMLvars.debug = false}}
\newcommand{\lowercasevarYVon}{\luadirect{YAMLvars.lowvasevarall = true}}
\newcommand{\lowercasevarYVoff}{\luadirect{YAMLvars.lowvasevarall = false}}
\newcommand{\AllowUndeclaredYV}{\luadirect{YAMLvars.setts.undeclared = true}}
@@ -130,8 +133,8 @@ YAMLvars.xfmDefault = {'lb2nl','addxspace'}
}}
\NewDocumentCommand{\setdefYAMLvars}{ m }{\luadirect{
- YAMLvars.updatesettskv(pl.tex._xFalse, \luastring{#1}, true)
-}}
+ YAMLvars.updatesettskv(\luastring{#1}, pl.tex._xFalse, true)
+}} % set the default settings
% \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}))}
diff --git a/macros/luatex/latex/yamlvars/yamlvars.tex b/macros/luatex/latex/yamlvars/yamlvars.tex
index 552fc21988..93e690d896 100644
--- a/macros/luatex/latex/yamlvars/yamlvars.tex
+++ b/macros/luatex/latex/yamlvars/yamlvars.tex
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2023-07-22
+% 2023-11-25
% Copyright (C) 2021-2023 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -54,6 +54,7 @@
\usepackage[overwritedefs]{yamlvars}
+\yamlvarsdebugon
\title{YAMLvars}
\subtitle{a YAML variable parser for LuaLaTeX}
@@ -80,13 +81,6 @@ or just find it easier to read document metadata from a YAML file compared to th
standard title, author, etc. commands.
\section{Package Options}
-\leavevmode\llap{\texttt{useyv}\ \ \ }By default, when you specify a YAML variable, it will be defined using \texttt{gdef}
-(only if it wasn't defined previously).
-If you use this setting, unless otherwise specified, YAML variables will be accessible under
-the \texttt{\textbackslash yv\{<var>\}} command.
-This also allows numbers and symbols in the variable names.
-Note that internally, the variables are stored in the command sequence
-\texttt{yv--<var>}.
\leavevmode\llap{\texttt{parseCLI}\ \ \ }If this option is enabled, any arguments passed to your lualatex compile
command that end in ``.yaml'' will be used, separated by a space.
@@ -105,6 +99,14 @@ 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.
+\leavevmode\llap{\texttt{useyv}\ \ \ }By default, when you specify a YAML variable, it will be defined using \texttt{gdef}
+(only if it wasn't defined previously).
+If you use this setting, unless otherwise specified, YAML variables will be accessible under
+the \texttt{\textbackslash yv\{<var>\}} command.
+This also allows numbers and symbols in the variable names.
+Note that internally, the variables are stored in the command sequence
+\texttt{yv--<var>}. This option is currently under repair and will not work properly in this version.
+
\section{Dependencies}
\llcmd{Note:}This package requires the \cmd{tinyyaml} package, available on CTAN.
@@ -119,6 +121,23 @@ like
\cmd{luacode}, \cmd{luakeys}, and
\cmd{etoolbox}.
+\section{Settings}
+\cmd{\setdefYAMLvars{kv}} changes the default settings of key-vals.\\
+\cmd{\setYAMLvars*{kv}} changes the current settings from key-vals. Use \cmd{*} if you want to first restore to defaults.
+
+ The \cmd{YAMLvars.setts} lua table contains the settings, which are:\\
+\cmd{parseopts} table passed to YAML parser options (default is \cmd{{timestamps=false}}) \\
+\cmd{decstr} in the declaration YAML text, if a value is a string, how should it be treated (\cmd{xfm, dft, or prc}) \\
+\cmd{undeclared} boolean for allowing parsing of undeclared vars \\
+\cmd{overwrite} boolean for allowing overwriting of previous definitions \\
+\cmd{lowercase} boolean for auto-changing vars to lowercase \\
+\cmd{prcstring} boolean for auto-converting final value before processing (sometimes) numbers can have odd effects \\
+%\cmd{tabmidrule} type of rule for tabu \\
+\cmd{xfm} default xfm function(s) if none passed to declared key, separated by space \\
+\cmd{prc} default prc function if none passed to declared key \\
+\cmd{dft} default dft function if none passed to declared key \\
+
+
\section{Declaring variables}
A declaration file can either be parsed with the command \texttt{declareYAMLvarsFile} command,
or, if you want to do it \LaTeX, you can put the YAML code in the \texttt{declareYAMLvars} environment.