texlive[73941] branches/branch2024.final/Master/texmf-dist: yamlvars

commits+karl at tug.org commits+karl at tug.org
Wed Feb 12 22:10:32 CET 2025


Revision: 73941
          https://tug.org/svn/texlive?view=revision&revision=73941
Author:   karl
Date:     2025-02-12 22:10:32 +0100 (Wed, 12 Feb 2025)
Log Message:
-----------
yamlvars (branch) (12feb25)

Modified Paths:
--------------
    branches/branch2024.final/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.pdf
    branches/branch2024.final/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.tex
    branches/branch2024.final/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.lua
    branches/branch2024.final/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.sty

Modified: branches/branch2024.final/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.pdf
===================================================================
(Binary files differ)

Modified: branches/branch2024.final/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.tex
===================================================================
--- branches/branch2024.final/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.tex	2025-02-12 21:10:23 UTC (rev 73940)
+++ branches/branch2024.final/Master/texmf-dist/doc/lualatex/yamlvars/yamlvars.tex	2025-02-12 21:10:32 UTC (rev 73941)
@@ -1,6 +1,6 @@
 % Kale Ewasiuk (kalekje at gmail.com)
-% 2024-08-17
-% Copyright (C) 2021-2023 Kale Ewasiuk
+% 2025-02-11
+% Copyright (C) 2021-2025 Kale Ewasiuk
 %
 % Permission is hereby granted, free of charge, to any person obtaining a copy
 % of this software and associated documentation files (the "Software"), to deal
@@ -55,9 +55,27 @@
 
 \usepackage[overwritedefs]{yamlvars}
 \yamlvarsdebugon
-\title{YAMLvars}
 \subtitle{a YAML variable parser for LuaLaTeX}
+\usepackage{geometry}
+\begin{declareYAMLvars}
+  title:
+    prc: setdocvar
+  geometry:
+    prc: keyvals
+  writePDFmetadatakv:
+    prc: keyvals
+\end{declareYAMLvars}
 
+\begin{parseYAMLvars}
+  title: YAMLvars
+  geometry:
+    left: 2in
+    right: 3in
+  writePDFmetadatakv:
+    title: yamlvars
+\end{parseYAMLvars}
+
+
 \begin{document}
 
 
@@ -64,13 +82,10 @@
 \maketitle
 
 
-%%%%%
 
-%{NOTE::: \Huge todo use LTXexample and improve examples/testing\\
-%todo need way better error tracing for this pkg}
+%todo need  way better error tracing for this pkg}
 
 
-
 %%%%%%%%%%%
 
 
@@ -130,7 +145,7 @@
 \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{prcstring}  a string with types (default 'number') for auto-converting final value before processing (sometimes) numbers can have odd effects. You might also include 'table'       \\
 %\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     \\
@@ -404,34 +419,7 @@
 \clearpage
 \section{xfm, dec, prc functions (from yamlvars.lua)}
 
-\lstinputlisting[linerange=111-315]{yamlvars.lua}
+\lstinputlisting[linerange=103-319]{yamlvars.lua}
 
-%
-%\AllowUndeclaredYV
-%\luadirect{YAMLvars.xfmDefault={'lb2nl','addxspace'}}
-
-%
-%\luadirect{YAMLvars.debug = true}
-%\setYAMLvars{undeclared, xfm= lb2nl addxspace}
-%\begin{parseYAMLvars}
-%kale: |-
-%  kale
-%  eee
-%\end{parseYAMLvars}
-%
-%\kale ee
-%
-%\setYAMLvars{undeclared, xfm=list2items}
-%\begin{parseYAMLvars}
-%lllist:
-%  - one
-%  - two
-%  - three
-%\end{parseYAMLvars}
-%
-%\begin{itemize}
-%  \lllist
-%\end{itemize}
-
 \end{document}
 

Modified: branches/branch2024.final/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.lua
===================================================================
--- branches/branch2024.final/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.lua	2025-02-12 21:10:23 UTC (rev 73940)
+++ branches/branch2024.final/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.lua	2025-02-12 21:10:32 UTC (rev 73941)
@@ -1,6 +1,6 @@
 --% Kale Ewasiuk (kalekje at gmail.com)
---% 2024-08-17
---% Copyright (C) 2021-2023 Kale Ewasiuk
+--% 2025-02-11
+--% Copyright (C) 2021-2025 Kale Ewasiuk
 --%
 --% Permission is hereby granted, free of charge, to any person obtaining a copy
 --% of this software and associated documentation files (the "Software"), to deal
@@ -28,6 +28,7 @@
 
 YAMLvars.yaml = require'tinyyaml' -- note: YAMLvars.sty will have checked existence of this already
 
+
 YAMLvars.luakeys = require'luakeys'()  -- note: YAMLvars.sty will have checked existence of this already
 
 local pl = penlight
@@ -57,7 +58,7 @@
 YAMLvars.setts.lowercase = false
 YAMLvars.setts.stripvars = true  -- todo add this as an option accessible in latex
 YAMLvars.setts.tabmidrule = 'midrule'
-YAMLvars.setts.prcstring = true
+YAMLvars.setts.prcstring = 'number'
 YAMLvars.setts.xfm = {}
 YAMLvars.setts.prc = 'gdef'
 YAMLvars.setts.dft = ''
@@ -296,6 +297,29 @@
 -- --
 
 
+
+YAMLvars.curr_keyvals = {}
+function YAMLvars.prc.keyvals(var, val)
+    YAMLvars.curr_keyvals[var] = val
+end
+function YAMLvars.callkeyvals()
+    for var, tbl in pairs(YAMLvars.curr_keyvals) do
+        local cmd = '\\'..var..'{'
+        for key, val in pairs(tbl) do
+            if tonumber(key) ~= nil then
+                cmd = cmd .. val
+            else
+                cmd = cmd .. key .. '=' .. val
+            end
+            cmd = cmd .. ','
+        end
+        tex.sprint(cmd..'}')
+    end
+    YAMLvars.curr_keyvals = {}
+end
+
+
+
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 
 function YAMLvars.makecmd(cs, val) -- provide command via lua
@@ -427,7 +451,7 @@
     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
+    if YAMLvars.setts.prcstring:find(type(val)) then
         val = tostring(val)
     end
     f(pl.stringx.strip(var), val) -- prc the value of the variable

Modified: branches/branch2024.final/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.sty
===================================================================
--- branches/branch2024.final/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.sty	2025-02-12 21:10:23 UTC (rev 73940)
+++ branches/branch2024.final/Master/texmf-dist/tex/lualatex/yamlvars/yamlvars.sty	2025-02-12 21:10:32 UTC (rev 73941)
@@ -1,6 +1,6 @@
 % Kale Ewasiuk (kalekje at gmail.com)
-% 2024-08-17
-% Copyright (C) 2021-2023 Kale Ewasiuk
+% 2025-02-11
+% Copyright (C) 2021-2025 Kale Ewasiuk
 %
 % Permission is hereby granted, free of charge, to any person obtaining a copy
 % of this software and associated documentation files (the "Software"), to deal
@@ -25,7 +25,7 @@
 
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{yamlvars}[2024-08-17]
+\ProvidesPackage{yamlvars}[2025-02-11]
 
 \RequirePackage{luacode}
 \RequirePackage{etoolbox}
@@ -37,6 +37,11 @@
 
 \luadirect{YAMLvars = require('YAMLvars')}
 
+\luadirect{
+  if YAMLvars.yaml == nil then
+      tex.sprint('\\PackageError{yamlvars}{"tinyyaml.lua" not found. Install the "lua-tinyyaml" package from CTAN or include "tinyyaml.lua" in your project}{}')
+  end
+}
 
 
 
@@ -92,6 +97,9 @@
 \luadirect{YAMLvars.setts2default()}
 
 
+\NewDocumentCommand{\YAMLvarsSetKeyVals}{}{\luadirect{YAMLvars.callkeyvals()}}
+
+
 \newcommand{\declareYAMLvarsFile}[1]{\luadirect{YAMLvars.declareYAMLvarsFile(\luastring{#1})}}
 \NewDocumentCommand{\parseYAMLvarsFile}{m}{\luadirect{
   YAMLvars.parseYAMLvarsFile(\luastring{#1})
@@ -110,7 +118,7 @@
 {\luadirect{
   penlight.tex.stoprecording()
 }}
-\AfterEndEnvironment{parseYAMLvars}{\luadirect{YAMLvars.parseYAMLvarsStr(penlight.tex.recordedbuf)}}
+\AfterEndEnvironment{parseYAMLvars}{\luadirect{YAMLvars.parseYAMLvarsStr(penlight.tex.recordedbuf)}\YAMLvarsSetKeyVals}
 % necessary hack to get rohead and lohead to work..
 % .. https://tex.stackexchange.com/questions/637018/setting-koma-heading-within-lua/637021?noredirect=1#comment1587387_637021
 



More information about the tex-live-commits mailing list.