texlive[62375] Master/texmf-dist: yamlvars (3mar22)
commits+karl at tug.org
commits+karl at tug.org
Thu Mar 3 22:08:22 CET 2022
Revision: 62375
http://tug.org/svn/texlive?view=revision&revision=62375
Author: karl
Date: 2022-03-03 22:08:22 +0100 (Thu, 03 Mar 2022)
Log Message:
-----------
yamlvars (3mar22)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.pdf
trunk/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.tex
trunk/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.lua
trunk/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.sty
Modified: trunk/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.tex 2022-03-03 21:08:05 UTC (rev 62374)
+++ trunk/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.tex 2022-03-03 21:08:22 UTC (rev 62375)
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje at gmail.com)
-% 2022-02-25
+% 2022-03-03
% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -53,7 +53,7 @@
\date{\today}
-
+\usepackage[pl,extrasnoglobals]{penlight}
\usepackage[overwritedefs]{YAMLvars}
\title{YAMLvars}
\subtitle{a YAML variable parser for LuaLaTeX}
Modified: trunk/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.lua 2022-03-03 21:08:05 UTC (rev 62374)
+++ trunk/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.lua 2022-03-03 21:08:22 UTC (rev 62375)
@@ -1,5 +1,5 @@
--% Kale Ewasiuk (kalekje at gmail.com)
---% 2022-02-25
+--% 2022-03-03
--% Copyright (C) 2021-2022 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -46,9 +46,15 @@
--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 = {} -- self table
+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
+
YAMLvars.xfm = {}
YAMLvars.prc = {}
YAMLvars.dec = {} -- table of declare function
@@ -70,13 +76,12 @@
YAMLvars.debug = false
-YAMLvars.yaml = require'markdown-tinyyaml' -- note: YAMLvars.sty will have checked existence of this already
-local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl
+
function YAMLvars.debugtalk(s, ss)
if YAMLvars.debug then
- help_wrt(s, ss)
+ pl.tex.help_wrt(s, ss)
end
end
@@ -130,7 +135,7 @@
end
-- todo need distinction beyyween table and penlight list ???
function YAMLvars.xfm.list2nl(var, val)
- return pl.tablex.join(val,'\\\\ ')
+ return pl.List(val):join('\\\\ ')
end
--val = pl.array2d.map_slice1(_1..'\\\\', val, 1,-2)
@@ -150,7 +155,7 @@
function YAMLvars.xfm.markdown(var, val)
--return '\\begin{markdown} '..val..'\n \\end{markdown}'
- help_wrt(val, md)
+ pl.tex.help_wrt(val, md)
return [[begin markdown ..val..
par end markdown]]
@@ -194,7 +199,7 @@
function YAMLvars.prc.toggle(t, v) -- requires penlight extras
local s = ''
- if hasval(v) then
+ if pl.hasval(v) then
s = '\\global\\toggletrue{'..t..'}'
else
s = '\\global\\togglefalse{'..t..'}'
@@ -358,15 +363,15 @@
if c == 0 then
return _YV_invalid_expression
else
- --help_wrt(s, var)
- --help_wrt(val, var)
+ --pl.tex.help_wrt(s, var)
+ --pl.tex.help_wrt(val, var)
YAMLvars.valTemp = val
YAMLvars.varTemp = var
- --help_wrt(s, 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')
- --help_wrt(s, var)
+ --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..'"}{}') --
@@ -431,30 +436,9 @@
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
--- https://tex.stackexchange.com/questions/38150/in-lualatex-how-do-i-pass-the-content-of-an-environment-to-lua-verbatim
-recordedbuf = ""
-function readbuf(buf)
- i,j = string.find(buf, '\\end{%w+}')
- if i==nil then -- if not ending an environment
- recordedbuf = recordedbuf .. buf .. "\n"
- return ""
- else
- return nil
- end
-end
-function startrecording()
- recordedbuf = ""
- luatexbase.add_to_callback('process_input_buffer', readbuf, 'readbuf')
-end
-function stoprecording()
- luatexbase.remove_from_callback('process_input_buffer', 'readbuf')
- recordedbuf = recordedbuf:gsub("\\end{%w+}\n","")
-end
-
-
function YAMLvars.doYAMLfiles(t)
if #t == 2 then
YAMLvars.declareYAMLvarsFile(t[1])
@@ -475,7 +459,7 @@
end
end
end
- --help_wrt(t)
+ --pl.tex.help_wrt(t)
return t
end
@@ -489,7 +473,7 @@
-- y = clean_tex_spaces(y)
--end
--local function clean_tex_spaces(s)
--- help_wrt(s)
+-- pl.tex.help_wrt(s)
-- if s:sub(1,2) == '%s' then
-- s, _ = s:gsub('%s+','',1)
-- end
Modified: trunk/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.sty 2022-03-03 21:08:05 UTC (rev 62374)
+++ trunk/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.sty 2022-03-03 21:08:22 UTC (rev 62375)
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje at gmail.com)
-% 2022-02-25
+% 2022-03-03
% 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-02-25]
+\ProvidesPackage{YAMLvars}[2022-03-03]
\IfFileExists{markdown-tinyyaml.lua}{}{\PackageError{YAMLvars}{This package requires installation of the 'markdown' package, please install it and try again}{}}
@@ -32,7 +32,7 @@
\RequirePackage{luacode}
\RequirePackage{xspace}
\RequirePackage{etoolbox}
-\RequirePackage[pl,extras]{penlight}
+\RequirePackage{penlight} % no option passed here, but extras must be used, error will be thrown if not
\luadirect{YAMLvars = require('YAMLvars')}
@@ -53,6 +53,9 @@
\luadirect{YAMLvars.debug = true}
}
+\newcommand{\AllowUndeclaredYV}{\luadirect{YAMLvars.allowUndeclared = true}}
+\newcommand{\ForbidUndeclaredYV}{\luadirect{YAMLvars.allowUndeclared = false}}
+
\DeclareOption*{\PackageWarning{YAMLvars}{Unknown option: '\CurrentOption'}{}}
\ProcessOptions\relax
@@ -61,15 +64,13 @@
\newcommand{\parseYAMLvarsFile}[1]{\luadirect{YAMLvars.parseYAMLvarsFile(\luastring{#1})}}
-\newenvironment{declareYAMLvars}{\luadirect{startrecording()}}{\luadirect{stoprecording()}
-\luadirect{YAMLvars.declareYAMLvarsStr(recordedbuf)}
+\newenvironment{declareYAMLvars}{\luadirect{pl.tex.startrecording()}}{\luadirect{pl.tex.stoprecording()}
+ \luadirect{YAMLvars.declareYAMLvarsStr(pl.tex.recordedbuf)}
}
-\newenvironment{parseYAMLvars}{\luadirect{startrecording()}}{\luadirect{stoprecording()}
-\luadirect{YAMLvars.parseYAMLvarsStr(recordedbuf)}
+\newenvironment{parseYAMLvars}{\luadirect{pl.tex.startrecording()}}{\luadirect{pl.tex.stoprecording()}
+ \luadirect{YAMLvars.parseYAMLvarsStr(pl.tex.recordedbuf)}
}
\newcommand{\resetYAMLvarsspec}{\luadirect{YAMLvars.varspec = {}}}
-\newcommand{\AllowUndeclaredYV}{\luadirect{YAMLvars.allowUndeclared = true}}
-\newcommand{\ForbidUndeclaredYV}{\luadirect{YAMLvars.allowUndeclared = false}}
More information about the tex-live-commits
mailing list.