summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/yamlvars
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-02-26 03:00:34 +0000
committerNorbert Preining <norbert@preining.info>2022-02-26 03:00:34 +0000
commit740a11f29a3551babe3d7edbb57ac3baa2280a3f (patch)
tree5d6d449e762f5ab95042e3517d03c5ac3ddaf7c3 /macros/luatex/latex/yamlvars
parent157cc9e776520d0b7d488317a69a10d4ae4d493b (diff)
CTAN sync 202202260300
Diffstat (limited to 'macros/luatex/latex/yamlvars')
-rw-r--r--macros/luatex/latex/yamlvars/yamlvars.lua (renamed from macros/luatex/latex/yamlvars/YAMLvars.lua)12
-rw-r--r--macros/luatex/latex/yamlvars/yamlvars.pdf (renamed from macros/luatex/latex/yamlvars/YAMLvars.pdf)bin69229 -> 69483 bytes
-rw-r--r--macros/luatex/latex/yamlvars/yamlvars.sty (renamed from macros/luatex/latex/yamlvars/YAMLvars.sty)5
-rw-r--r--macros/luatex/latex/yamlvars/yamlvars.tex (renamed from macros/luatex/latex/yamlvars/YAMLvars.tex)10
4 files changed, 17 insertions, 10 deletions
diff --git a/macros/luatex/latex/yamlvars/YAMLvars.lua b/macros/luatex/latex/yamlvars/yamlvars.lua
index 93234e5d59..1f95a50f25 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-01-18
+--% 2022-02-25
--% Copyright (C) 2021-2022 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -56,9 +56,9 @@ YAMLvars.dec = {} -- table of declare function
YAMLvars.varsvals = {}
YAMLvars.varspecs = {}
+YAMLvars.xfmDefault = {}
YAMLvars.prcDefault = 'gdef'
YAMLvars.dftDefault = nil
-YAMLvars.xfmDefault = {}
YAMLvars.allowUndeclared = false
YAMLvars.overwritedefs = false
@@ -83,7 +83,7 @@ end
-- xfm functions (transforms) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
function YAMLvars.xfm.addxspace(var, val)
- return val .. '\\xspace{}'
+ return val .. '\\xspace'
end
function YAMLvars.xfm.tab2arr(var, val)
@@ -348,6 +348,11 @@ end
local _YV_invalid_expression = '\1 invalid expression'
local _YV_no_return = '\2 no return val'
+
+local function expr_err(var, val)
+ tex.print('\\PackageError{YAMLvars}{xfm with "= or /" error on var "'..var..'"}{}') -- todo make program stop
+end
+
local function eval_expr(func, var, val)
local s, c = func:gsub('^[=/]', {['/'] = '\2', ['='] = 'YAMLvars.valTemp = '}, 1) -- / is run code, = sets val = code
if c == 0 then
@@ -367,6 +372,7 @@ local function eval_expr(func, var, val)
tex.print('\\PackageError{YAMLvars}{xfm with "= or /" error on var "'..var..'"}{}') --
end
if c > 0 then
+ expr_err(var)
return _YV_no_return
end
return YAMLvars.valTemp
diff --git a/macros/luatex/latex/yamlvars/YAMLvars.pdf b/macros/luatex/latex/yamlvars/yamlvars.pdf
index 974873680d..bdb6b811da 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 73c40ba693..8e295988fb 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-01-18
+% 2022-02-25
% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -25,7 +25,7 @@
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{YAMLvars}[2022-01-18]
+\ProvidesPackage{YAMLvars}[2022-02-25]
\IfFileExists{markdown-tinyyaml.lua}{}{\PackageError{YAMLvars}{This package requires installation of the 'markdown' package, please install it and try again}{}}
@@ -72,3 +72,4 @@
\newcommand{\resetYAMLvarsspec}{\luadirect{YAMLvars.varspec = {}}}
\newcommand{\AllowUndeclaredYV}{\luadirect{YAMLvars.allowUndeclared = true}}
+\newcommand{\ForbidUndeclaredYV}{\luadirect{YAMLvars.allowUndeclared = false}}
diff --git a/macros/luatex/latex/yamlvars/YAMLvars.tex b/macros/luatex/latex/yamlvars/yamlvars.tex
index 057aac5d39..a61df03024 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-01-18
+% 2022-02-25
% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -101,8 +101,8 @@ An example is showin in Section \ref{example}.
\hspace*{3ex}\llcmd{allowundeclared}%
It might be helpful to define something in your YAML parsing doc without declaring it.
-If you want this flexibility, use this setting. Note that eisting definitions will not be overwritten and an error
-will br thrown if the name exists.
+If you want this flexibility, use this setting. Note that existing definitions will not be overwritten and an error
+will br thrown if the name exists. Alternatively, you can use the commands \cmd{\AllowUndeclaredYV} or \cmd{\ForbidUndeclaredYV} to toggle this behavior.
\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.
@@ -186,14 +186,14 @@ Here is an example of a parsing document.
\begin{verbatim}
-\begin{declareYAMLvars}
+\begin{parseYAMLvars}
Location: Planet Earth
People: # a YAML list
- Some One # turns into Lua table
- No Body
# company assumed Amazon if not set here
Rhead: \today
-\end{declareYAMLvars}
+\end{parseYAMLvars}
\end{verbatim}