diff options
Diffstat (limited to 'macros/luatex')
-rw-r--r-- | macros/luatex/generic/luamplib/NEWS | 3 | ||||
-rw-r--r-- | macros/luatex/generic/luamplib/luamplib.dtx | 18 | ||||
-rw-r--r-- | macros/luatex/generic/luamplib/luamplib.pdf | bin | 153620 -> 153614 bytes | |||
-rw-r--r-- | macros/luatex/generic/penlightplus/penlightplus.lua | 124 | ||||
-rw-r--r-- | macros/luatex/generic/penlightplus/penlightplus.pdf | bin | 65123 -> 66585 bytes | |||
-rw-r--r-- | macros/luatex/generic/penlightplus/penlightplus.sty | 26 | ||||
-rw-r--r-- | macros/luatex/generic/penlightplus/penlightplus.tex | 77 | ||||
-rw-r--r-- | macros/luatex/latex/yamlvars/yamlvars.lua | 16 | ||||
-rw-r--r-- | macros/luatex/latex/yamlvars/yamlvars.pdf | bin | 83795 -> 85254 bytes | |||
-rw-r--r-- | macros/luatex/latex/yamlvars/yamlvars.sty | 12 | ||||
-rw-r--r-- | macros/luatex/latex/yamlvars/yamlvars.tex | 7 |
11 files changed, 195 insertions, 88 deletions
diff --git a/macros/luatex/generic/luamplib/NEWS b/macros/luatex/generic/luamplib/NEWS index 72bd87b2ff..5baf7e6a34 100644 --- a/macros/luatex/generic/luamplib/NEWS +++ b/macros/luatex/generic/luamplib/NEWS @@ -1,5 +1,8 @@ History of the luamplib package +2023/12/08 2.25.2 + * info instead of warning when compiling with dviluatex + 2023/08/21 2.25.1 * explicit \par in \mplibstoptoPDF to support LaTeX's paragraph hooks diff --git a/macros/luatex/generic/luamplib/luamplib.dtx b/macros/luatex/generic/luamplib/luamplib.dtx index 949f69c5fe..023c73b933 100644 --- a/macros/luatex/generic/luamplib/luamplib.dtx +++ b/macros/luatex/generic/luamplib/luamplib.dtx @@ -85,7 +85,7 @@ See source file '\inFileName' for licencing and contact information. %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{luamplib.drv}% - [2023/08/21 v2.25.1 Interface for using the mplib library]% + [2023/12/08 v2.25.2 Interface for using the mplib library]% \documentclass{ltxdoc} \usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace} \usepackage[x11names]{xcolor} @@ -153,7 +153,7 @@ See source file '\inFileName' for licencing and contact information. % \author{Hans Hagen, Taco Hoekwater, Elie Roux, Philipp Gesang and Kim Dohyun\\ % Maintainer: LuaLaTeX Maintainers --- % Support: \email{lualatex-dev@tug.org}} -% \date{2023/08/21 v2.25.1} +% \date{2023/12/08 v2.25.2} % % \maketitle % @@ -446,8 +446,8 @@ See source file '\inFileName' for licencing and contact information. luatexbase.provides_module { name = "luamplib", - version = "2.25.1", - date = "2023/08/21", + version = "2.25.2", + date = "2023/12/08", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", } @@ -2065,7 +2065,7 @@ luamplib.colorconverter = colorconverter \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} - [2023/08/21 v2.25.1 mplib package for LuaTeX] + [2023/12/08 v2.25.2 mplib package for LuaTeX] \ifx\newluafunction\@undefined \input ltluatex \fi @@ -2101,17 +2101,17 @@ luamplib.colorconverter = colorconverter % % luamplib works in both PDF and DVI mode, % but only DVIPDFMx is supported currently among a number of DVI tools. -% So we output a warning. +% So we output a info. % \begin{macrocode} \ifnum\pdfoutput>0 \let\mplibtoPDF\pdfliteral \else \def\mplibtoPDF#1{\special{pdf:literal direct #1}} - \ifcsname PackageWarning\endcsname - \PackageWarning{luamplib}{take dvipdfmx path, no support for other dvi tools currently.} + \ifcsname PackageInfo\endcsname + \PackageInfo{luamplib}{take dvipdfmx path, no support for other dvi tools currently.} \else \write128{} - \write128{luamplib Warning: take dvipdfmx path, no support for other dvi tools currently.} + \write128{luamplib Info: take dvipdfmx path, no support for other dvi tools currently.} \write128{} \fi \fi diff --git a/macros/luatex/generic/luamplib/luamplib.pdf b/macros/luatex/generic/luamplib/luamplib.pdf Binary files differindex 301e428103..a8022cc75b 100644 --- a/macros/luatex/generic/luamplib/luamplib.pdf +++ b/macros/luatex/generic/luamplib/luamplib.pdf diff --git a/macros/luatex/generic/penlightplus/penlightplus.lua b/macros/luatex/generic/penlightplus/penlightplus.lua index 84cd2094ff..6aa1331fdd 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-11-25 +--% 2023-12-08 --% Copyright (C) 2021-2023 Kale Ewasiuk --% --% Permission is hereby granted, free of charge, to any person obtaining a copy @@ -7,7 +7,7 @@ --% 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: +--% furnished to do so, subjdeect to the following conditions: --% --% The above copyright notice and this permission notice shall be included in --% all copies or substantial portions of the Software. @@ -24,6 +24,7 @@ +-- https://lunarmodules.github.io/Penlight/ __PL_PLUS__ = true __PL_SKIP_TEX__ = __PL_SKIP_TEX__ or false --if declared true before here, it will use regular print functions @@ -34,7 +35,6 @@ __PL_NO_HYPERREF__ = __PL_NO_HYPERREF__ or false penlight.luakeys = require'luakeys'() - penlight.COMP = require'pl.comprehension'.new() -- for comprehensions -- http://lua-users.org/wiki/SplitJoin -- todo read me!! @@ -63,14 +63,16 @@ end -- Some simple and helpful LaTeX functions -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- xparse defaults -penlight.tex._xTrue = '\\BooleanTrue ' -penlight.tex._xFalse = '\\BooleanFalse ' -penlight.tex._xNoValue = '-NoValue-' penlight.tex.xTrue = '\\BooleanTrue ' penlight.tex.xFalse = '\\BooleanFalse ' penlight.tex.xNoValue = '-NoValue-' +penlight.tex._xTrue = '\\BooleanTrue ' +penlight.tex._xFalse = '\\BooleanFalse ' +penlight.tex._xNoValue = '-NoValue-' + + --Generic LuaLaTeX utilities for print commands or environments if not __PL_SKIP_TEX__ then @@ -130,7 +132,7 @@ function penlight.tex.prtt(tab, d1, d2) -- prints a table with new line between end end -function penlight.tex.help_wrt(s1, s2) -- helpful printing, makes it easy to debug, s1 is object, s2 is note +function penlight.tex.wrth(s1, s2) -- helpful printing, makes it easy to debug, s1 is object, s2 is note local wrt2 = wrt or texio.write_nl or print s2 = s2 or '' wrt2('\nvvvvv '..s2..'\n') @@ -141,9 +143,8 @@ function penlight.tex.help_wrt(s1, s2) -- helpful printing, makes it easy to deb end wrt2('\n^^^^^\n') end -penlight.help_wrt = penlight.tex.help_wrt +penlight.help_wrt = penlight.tex.wrth penlight.wrth = penlight.help_wrt -penlight.tex.wrth = penlight.help_wrt function penlight.tex.prt_array2d(t) for _, r in ipairs(t) do @@ -455,6 +456,23 @@ function str_mt.__index.subpar(s, r) end +function str_mt.__index.fmt(s, t, fmt) -- format a $1 string with an array or table and formats + -- formats can be a luakeys string, or a table + fmt = fmt or {} + if type(fmt) == 'string' then + fmt = penlight.tablex.strinds(penlight.luakeys.parse(fmt, {naked_as_value=true})) + end + if type(t) ~= 'table' then t = {t} end + t = penlight.tablex.strinds(t) + for k, f in pairs(fmt) do -- apply formats + t[k] = string.format('%'..f, t[tostring(k)]) + end + return s % t +end + + + + -- -- -- -- function stuff function penlight.clone_function(fn) @@ -501,6 +519,18 @@ end -- table stuff below +function penlight.tablex.strinds(t) -- convert indices that are numbers to string indices + local t_new = {} + for i, v in pairs(t) do -- ensure all indexes are strings + if type(i) == 'number' then + t_new[tostring(i)] = v + else + t_new[i] = v + end + end + return t_new +end + function penlight.tablex.map_slice(func, T, j1, j2) if type(j1) == 'string' then @@ -783,6 +813,13 @@ penlight.tbls = {} penlight.rec_tbl = '' penlight.rec_tbl_opts = {} +function penlight.get_tbl_name(s) + if s == '' then + return penlight.rec_tbl + end + return s +end + function penlight.get_tbl_index(s) local tbl = '' local key = '' @@ -844,24 +881,52 @@ function penlight.check_recent_tbl_undefault() end end - -penlight.tbl_xysep = '%s+' -- spaces separate x-y coords +-- TODO TODO TODO get error working xy def, and referene which table for key-vals +penlight.tbl_xysep = '%s+' -- spaces separate x-y coordinates 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 + if (not penlight.hasval(x)) or (not 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 +-- + +function penlight.make_tex_global() + for k,v in pairs(penlight.tex) do -- make tex functions global + _G[k] = v + end +end + + +penlight.kpairs = penlight.utils.kpairs +penlight.npairs = penlight.utils.npairs +penlight.writefile = penlight.utils.writefile +penlight.readfile = penlight.utils.readfile +penlight.readlines = penlight.utils.readfile +penlight.filterfiles = penlight.utils.filterfiles + +-- adopt table functions in tablex +penlight.tablex.concat = table.concat +penlight.tablex.insert = table.insert +penlight.tablex.maxn = table.maxn +penlight.tablex.remove = table.remove +penlight.tablex.sort = table.sort + +penlight.tbx = penlight.tablex +penlight.a2d = penlight.array2d + if penlight.hasval(__PL_GLOBALS__) then -- iterators kpairs = penlight.utils.kpairs npairs = penlight.utils.npairs - --enum = utils.enum + + hasval = penlight.hasval + COMP = penlight.COMP for k,v in pairs(penlight.tablex) do -- extend the table table to contain tablex functions if k == 'sort' then @@ -873,38 +938,15 @@ if penlight.hasval(__PL_GLOBALS__) then end end table.join = table.concat -- alias - -- todo should tablex have all table functions - - penlight.tablex.concat = table.concat - penlight.tablex.insert = table.insert - penlight.tablex.maxn = table.maxn - penlight.tablex.remove = table.remove - penlight.tablex.sort = table.sort - - hasval = penlight.hasval - COMP = penlight.COMP - - -- shortcuts --- http://stevedonovan.github.io/Penlight/api/libraries/penlight.utils.html - penlight.writefile = penlight.utils.writefile - penlight.readfile = penlight.utils.readfile - penlight.readlines = penlight.utils.readfile - penlight.filterfiles = penlight.utils.filterfiles - - penlight.a2 = penlight.array2d - A2d = penlight.array2d - penlight.tbl = penlight.tablex - TX = penlight.tablex - - for k,v in pairs(penlight.tex) do -- make tex functions global - _G[k] = v - end + a2d = penlight.array2d + tbx = penlight.tablex end +-- graveyard --_xTrue = penlight.tex._xTrue --_xFalse = penlight.tex._xFalse diff --git a/macros/luatex/generic/penlightplus/penlightplus.pdf b/macros/luatex/generic/penlightplus/penlightplus.pdf Binary files differindex 7e273cb6c1..17d95268eb 100644 --- a/macros/luatex/generic/penlightplus/penlightplus.pdf +++ b/macros/luatex/generic/penlightplus/penlightplus.pdf diff --git a/macros/luatex/generic/penlightplus/penlightplus.sty b/macros/luatex/generic/penlightplus/penlightplus.sty index 97083c6bff..f5ffc0f176 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-11-25 +% 2023-12-08 % 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-11-25] +\ProvidesPackage{penlightplus}[2023-12-08] \RequirePackage{luacode} \RequirePackage{luakeys} @@ -105,14 +105,13 @@ %%% tbls below -\NewDocumentCommand{\tblnew}{m}{\luadirect{% initialize a tbl +\NewDocumentCommand{\tblnew}{m}{\luadirect{% initialize a tbl and set blank penlight.tbls[\luastring{#1}] = {} penlight.rec_tbl = \luastring{#1} }} \NewDocumentCommand{\tblfrkv}{m +m O{}}{\luadirect{% penlight.rec_tbl_opts = penlight.luakeys.parse(\luastring{#3}) - penlight.wrth(\luastring{#2}, '??') penlight.tbls[\luastring{#1}] = penlight.luakeys.parse(string.subpar(\luastring{#2}), penlight.rec_tbl_opts) penlight.rec_tbl = \luastring{#1} }} @@ -141,10 +140,25 @@ penlight.set_tbl_item(\luastring{#1}, \luastring{#2}) }} -\NewDocumentCommand{\tbldef}{ m m }{\luadirect{% define a table, use * to make definition - token.set_macro(\luastring{#2}, tostring(penlight.get_tbl_item(\luastring{#1}))) +% todo if no definition is provided, assume <tblname><key> +\NewDocumentCommand{\tbldef}{ m m }{\luadirect{% define a {table key}{def} + local _tbl, _key = penlight.get_tbl_index(\luastring{#1}) + local _tbl_def_ = \luastring{#2} + if _tbl_def_ == '' then _tbl_def_ = 'dtbl'.._tbl.._key end + token.set_macro(_tbl_def_, tostring(penlight.tbls[_tbl][_key])) }} +\NewDocumentCommand{\tbldefall}{ m m }{\luadirect{% define all {table} keys to {table} \table<key1> + % todo maybe change tbldef {def} to [def] and make same as table name + local _tbl = penlight.get_tbl_name(\luastring{#1}) + local _tbl_def_ = \luastring{#2} + if _tbl_def_ == '' then _tbl_def_ = 'dtbl'.._tbl end + for k, v in pairs(penlight.tbls[_tbl]) do + token.set_macro(_tbl_def_..k, tostring(v)) + end +}} + + \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') }} diff --git a/macros/luatex/generic/penlightplus/penlightplus.tex b/macros/luatex/generic/penlightplus/penlightplus.tex index 169364847c..988a51bb2a 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-11-25 +% 2023-12-08 % Copyright (C) 2021-2023 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy @@ -104,8 +104,26 @@ Some functionality is added to penlight and 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{upfirst(s)} uppercase first letter\\ +\llcmd{string.}\cmd{delspace(s)} delete all spaces\\ +\llcmd{string.}\cmd{trimfl(s)}remove first and last chars\\ +\llcmd{string.}\cmd{appif(s, append, bool, alternate)}\\ +\llcmd{string.}\cmd{gfirst(s, t)}return first matched patter from an array of patterns t\\ +%\llcmd{string.}\cmd{gnum(s)} extract a number from a string\\ +\llcmd{string.}\cmd{gextract(s)} extract a pattern from a string (returns capture and new string with capture removed)\\ \llcmd{string.}\cmd{totable(s)} string a table of characters\\ +\llcmd{string.}\cmd{tolist(s)} string a table of characters\\ +\llcmd{string.}\cmd{containsany(s,t)} checks if any of the array of strings \cmd{t} are in \cmd{s} using \cmd{string.find}\\ +\llcmd{string.}\cmd{containsanycase(s,t)} case-insensitive version\\ \llcmd{string.}\cmd{delspace(s)} clear spaces from string\\ +\llcmd{string.}\cmd{subpar(s, c)} replaces \cmd{\\par} with a character of your choice default is space\\ +\llcmd{string.}\cmd{fmt(s, t, fmt)} format a string like \cmd{format_operator}, but with +a few improvements. \cmd{t} can be an array (reference items like \cmd{\$1} in the string), +and \cmd{fmt} can be a table of formats (keys correspond to those in \cmd{t}), or a string that +is processed by luakeys.\\ + \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.\\ @@ -122,7 +140,7 @@ Some functionality is added to penlight and Lua. \llcmd{prt(x),prtn(x)} print without or with a newline at end. Tries to help with special characters or numbers printing.\\ \llcmd{prtl(l),prtt(t)} print a literal string, or table\\ \llcmd{wrt(x), wrtn(x)} write to log\\ -\llcmd{help_wrt}\cmd{(s1, s2)} pretty-print something to console. S2 is a flag to help you find., alias is \cmd{wrth}\\ +\llcmd{wrh}\cmd{(s1, s2)} pretty-print something to console. S2 is a flag to help you find., alias is \cmd{help_wrt}, also in \cmd{pl.wrth}\\ \llcmd{prt_array2d(tt)} pretty print a 2d array\\ \\ \llcmd{pkgwarn}\cmd{(pkg, msg1, msg2)} throw a package warning\\ @@ -142,9 +160,11 @@ is true, it will overwrite an existing command (using \cmd{defcmd}), otherwise, \subsubsection*{global extras} If the package option \cmd{globals} is used, many additional globals are set for easier scripting. -All \cmd{pl.tex} functions, and variables, \cmd{pl.hasval}, \cmd{pl.COMP}, \cmd{pl.utils.kpairs}, \cmd{pl.utils.npairs} become globals. -\cmd{pl.tablex} is aliased as \cmd{TX} (which also includes all native Lua table functions), and -\cmd{pl.array2d} is aliased as \cmd{A2d}. +\cmd{pl.hasval}, \cmd{pl.COMP}, \cmd{pl.utils.kpairs}, \cmd{pl.utils.npairs} become globals. +\cmd{pl.tablex} is aliased as \cmd{pl.tbx and tbx} (which also includes all native Lua table functions), and +\cmd{pl.array2d} is aliased as \cmd{pl.a2d and a2d}. + +If you want global \cmd{pl.tex} funcs and vars, call \cmd{pl.make_tex_global()} \\ @@ -198,6 +218,7 @@ no, once, twice, or full expansion. For example, we can control the expansion of \cmd{penlightplus} provides a Lua-table interface. Tables are stored in the \cmd{penlight.tbls} table. +%%% \cmd{\tblnew{t}} declares a new table with name \cmd{t}\\ \cmd{\tblchg{t}} changes the 'recent' table\\ @@ -206,7 +227,8 @@ no, once, twice, or full expansion. For example, we can control the expansion of \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{\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{\tbldef{i}{d}} pushes the value to macro \cmd{d}\\ +\cmd{\tbldefall{t}{d}} define all item in table \cmd{t} (use recent if blank) with format \cmd{d<key>}, if \cmd{d} is blank, commands are defined as \cmd{tbl<t><k>} \\ \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}\\ @@ -232,9 +254,13 @@ or simply use \cmd{ind} without the table name, where the assumed table is the l \tblifv{y}{tR}[fA]\\ %% \kvtblundefcheck % would throw error \tbldef{my.first}{mydef} \mydef\\ +\tbldef{first}{}\dtblmyfirst\\ {\tbldef{last}{mydef} \mydef} \mydef\\ {\tblgdef{last}{mydef}} \mydef\\ +\tbldefall{}{}\dtblmyfirst\\ +\tbldefall{my}{DEF}\DEFfirst + \tblset{my.a}{12 36} \tbldefxy{my.a}{coord} (\coordx,\coordy) @@ -248,17 +274,16 @@ or simply use \cmd{ind} without the table name, where the assumed table is the l \end{LTXexample} -\tblfrcsv{me}{ -Hello=world, - - -Bonjour=terre, -} -\tblget{Hello} -\tblget{Bonjour} +%\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}. +Note: for this 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. @@ -312,5 +337,25 @@ You can do a similar string split but to \cmd{\item} instead of commas with \cmd % } % % \THINg[color=blue,size=tiny]{Kale} - +% +%\begin{luacode*} +%penlight.wrth(('$1'):fmt(5.5,'.8f','XYZ')) +%function prttol() +% penlight.tbls.tol[3] = penlight.tbls.tol[3] or 3 +% penlight.tbls.tol[4] = penlight.tbls.tol[1]*(1.0-penlight.tbls.tol[3]/100.0) + 0.0 +% penlight.tbls.tol[5] = penlight.tbls.tol[1]*(1.0+penlight.tbls.tol[3]/100.0) + 0.0 +% penlight.tbls.tol['k'] = 'fuckboi' +% penlight.wrth(('$k $1\\$2 (\\pmpct{$3} tolerance, $4\\ndash$5\\$2)'):fmt(penlight.tbls.tol, '4=.1f, 5=.1f'), 'XYZ') +%end +%\end{luacode*} +%\NewDocumentCommand{\prttol}{ m }{% {50.0,kV,3} % 50\us (\pmpct{20} tolerance, 40=--60\us) +%\tblfrcsv{tol}{#1}\luadirect{prttol()}} +% +%\prttol{50,kV,3.21} +% +%\begin{luacode*} +%--pl.wrth(('2.23'):gnum()) +%\end{luacode*} + + \end{document}
\ No newline at end of file diff --git a/macros/luatex/latex/yamlvars/yamlvars.lua b/macros/luatex/latex/yamlvars/yamlvars.lua index d6d2f7ca4f..29393bd5a1 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-11-25 +--% 2023-12-08 --% Copyright (C) 2021-2023 Kale Ewasiuk --% --% Permission is hereby granted, free of charge, to any person obtaining a copy @@ -51,7 +51,7 @@ 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.decstr = 'xfm' -- if in declaration key the value is a string (instead of dec/xfm/prc table), how should it be treated YAMLvars.setts.undeclared = false YAMLvars.setts.overwrite = false YAMLvars.setts.lowercase = false @@ -96,6 +96,8 @@ end + + function YAMLvars.xfm.markdown(var, val) --return '\\begin{markdown} '..val..'\n \\end{markdown}' pl.tex.help_wrt(val, md) @@ -195,7 +197,7 @@ function YAMLvars.dec.gdef(var, dft) end function YAMLvars.dec.yvdef(var, dft) - YAMLvars.deccmd('yv--'..var, dft) + YAMLvars.deccmd('yv'..var, dft) end function YAMLvars.dec.toggle(var, dft) @@ -219,8 +221,8 @@ function YAMLvars.prc.gdef(var, val) end function YAMLvars.prc.yvdef(var, val) - pl.tex.defmacro('yv--'..var, val) - YAMLvars.debugtalk('yv--'..var..' = '..val, 'prc yvdef') + pl.tex.defcmd('yv'..var, val) + YAMLvars.debugtalk('yv'..var..' = '..val, 'prc yvdef') end function YAMLvars.prc.toggle(t, v) -- requires penlight extras @@ -423,13 +425,13 @@ local function transform_and_prc(var, val) if YAMLvars.setts.prcstring then val = tostring(val) end - f(var, val) -- prc the value of the variable + f(pl.stringx.strip(var), val) -- prc the value of the variable end function YAMLvars.parseYAMLvarsStr(y) - YAMLvars.debugtalk(YAMLvars.varsvals, 'Parsing YAML vars with table') + YAMLvars.debugtalk('', 'Parsing YAML vars...') YAMLvars.varsvals = YAMLvars.yaml.parse(y, YAMLvars.setts.parseopts) for var, val in pairs(YAMLvars.varsvals) do if YAMLvars.varslowcase:contains(var:lower()) then diff --git a/macros/luatex/latex/yamlvars/yamlvars.pdf b/macros/luatex/latex/yamlvars/yamlvars.pdf Binary files differindex 013335b3ad..3a820bb148 100644 --- a/macros/luatex/latex/yamlvars/yamlvars.pdf +++ b/macros/luatex/latex/yamlvars/yamlvars.pdf diff --git a/macros/luatex/latex/yamlvars/yamlvars.sty b/macros/luatex/latex/yamlvars/yamlvars.sty index bd0643ec57..524b290f34 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-11-25 +% 2023-12-08 % 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-11-25] +\ProvidesPackage{yamlvars}[2023-12-08] \RequirePackage{luacode} \RequirePackage{etoolbox} @@ -37,10 +37,12 @@ \luadirect{YAMLvars = require('YAMLvars')} + + + + \DeclareOption{useyv}{ - \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})))}} + \NewDocumentCommand{\yv}{m}{\csuse{yv#1}} \luadirect{YAMLvars.setts.prc = 'yvdef'} \luadirect{YAMLvars.settsdefault.prc = 'yvdef'} } diff --git a/macros/luatex/latex/yamlvars/yamlvars.tex b/macros/luatex/latex/yamlvars/yamlvars.tex index 93e690d896..3b00000feb 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-11-25 +% 2023-12-08 % Copyright (C) 2021-2023 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy @@ -103,9 +103,8 @@ will br thrown if the name exists. Alternatively, you can use the commands \cmd{ (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. +\cmd{\yv<var>}. \section{Dependencies} \llcmd{Note:}This package requires the \cmd{tinyyaml} package, available on CTAN. @@ -404,7 +403,7 @@ Items: \clearpage \section{xfm, dec, prc functions (from yamlvars.lua)} -\lstinputlisting[linerange=113-296]{yamlvars.lua} +\lstinputlisting[linerange=111-315]{yamlvars.lua} % %\AllowUndeclaredYV |