diff options
-rw-r--r-- | Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.pdf | bin | 69483 -> 69460 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.tex | 4 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.lua | 54 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.sty | 19 |
4 files changed, 31 insertions, 46 deletions
diff --git a/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.pdf b/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.pdf Binary files differindex bdb6b811da3..864a0842d4c 100644 --- a/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.pdf +++ b/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.pdf diff --git a/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.tex b/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.tex index a61df030241..1c412c2f6d1 100644 --- a/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.tex +++ b/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.tex @@ -1,5 +1,5 @@ % Kale Ewasiuk (kalekje@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} diff --git a/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.lua b/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.lua index 1f95a50f250..f32627a21a4 100644 --- a/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.lua +++ b/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.lua @@ -1,5 +1,5 @@ --% Kale Ewasiuk (kalekje@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 + +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 = {} -- self table YAMLvars.xfm = {} YAMLvars.prc = {} YAMLvars.dec = {} -- table of declare function @@ -70,13 +76,12 @@ YAMLvars.tabmidrule = 'hline' 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 @@ function YAMLvars.xfm.arrsortlastnameAZ(var, val) 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 @@ end 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 @@ end 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 @@ local function eval_expr(func, var, val) 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,27 +436,6 @@ end -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --- 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 @@ -475,7 +459,7 @@ function YAMLvars.getYAMLcli() end end end - --help_wrt(t) + --pl.tex.help_wrt(t) return t end @@ -489,7 +473,7 @@ return YAMLvars -- 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 diff --git a/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.sty b/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.sty index 8e295988fbf..1c4b8fcf322 100644 --- a/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.sty +++ b/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.sty @@ -1,5 +1,5 @@ % Kale Ewasiuk (kalekje@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,14 +25,14 @@ \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}{}} \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}} |