texlive[74021] branches/branch2024.final/Master/texmf-dist: luatbls

commits+karl at tug.org commits+karl at tug.org
Sat Feb 15 22:32:48 CET 2025


Revision: 74021
          https://tug.org/svn/texlive?view=revision&revision=74021
Author:   karl
Date:     2025-02-15 22:32:48 +0100 (Sat, 15 Feb 2025)
Log Message:
-----------
luatbls (branch) (15feb25)

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

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

Modified: branches/branch2024.final/Master/texmf-dist/doc/lualatex/luatbls/luatbls.tex
===================================================================
--- branches/branch2024.final/Master/texmf-dist/doc/lualatex/luatbls/luatbls.tex	2025-02-15 21:32:40 UTC (rev 74020)
+++ branches/branch2024.final/Master/texmf-dist/doc/lualatex/luatbls/luatbls.tex	2025-02-15 21:32:48 UTC (rev 74021)
@@ -1,5 +1,5 @@
 % Kale Ewasiuk (kalekje at gmail.com)
-% 2025-01-05
+% 2025-02-14
 % Copyright (C) 2025 Kale Ewasiuk
 %
 % Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -23,7 +23,9 @@
 % OR OTHER DEALINGS IN THE SOFTWARE.
 
 
+
 \documentclass[11pt,parskip=half]{scrartcl}
+\usepackage[default]{lato}
 \usepackage[left=0.75in,right=0.75in,top=1in,bottom=1in]{geometry}
 \setlength{\parindent}{0ex}
 \newcommand{\llcmd}[1]{\leavevmode\llap{\texttt{\detokenize{#1}}}}
@@ -97,7 +99,7 @@
 \llcmd{opts }: options for \cmd{luakeys.parse()}.\\
 \llcmd{cstemp }: a template for command-sequences, lengths, or toggles. By default is \cmd{ltbl<t><k>}.\\
 
-There are a few ways to use the index (placeholder \cmd{i}.\\
+There are a few ways to use the index (placeholder \cmd{i}).\\
 \cmd{t.k} where \cmd{t} is the table name and \cmd{k} is a string key (i.e. uses \cmd{luatbls.t.k}),\\
 \cmd{t/n} where \cmd{n} is an integer index (i.e. uses \cmd{t.k[n]}); note that negative indexes are allowed where -1 is the last element.
 Alternatively, \cmd{t} and the symbol can be omitted, and simply pass the element without the table name as a prefix,
@@ -140,13 +142,16 @@
 \cmd{\tblchg{t}} changes the 'recent' table\\
 \\
 \cmd{\tblfrkv{t}{keyval}[opts]} new table from key-vals using \cmd{luakeys} \\
-\cmd{\tblfrkvN{t}{keyval}[opts]} does not expand key-val string \cmd{luakeys} \\
-
+\cmd{\tblfrkvN{t}{keyval}[opts]} does not expand key-val string \cmd{luakeys}. Note:
+\cmd{opts} are parsed using luakeys with the \cmd{naked_as_value=true}, so booleans must be explicitly set.\\
+\\
+ \cmd{\tblfrcsv{t}{csv}[opts]} a shorthand \cmd{\tblfrkv{t}{csv}[naked_as_value=true,opts]}, a good way to convert  a comma-separated list to an array\\
+ \cmd{\tblfrcsvN{t}{csv}[opts]} same as above, but the csv is not expanded.\\
+\\
 \cmd{\tblkvundefcheck} will throw an error if you use define a table from key-values
 and use a key that was not specified in the luakeys parse options via \cmd{opts.defaults} or \cmd{opts.defs}.\\
 \\
- \cmd{\tblfrcsv{t}{csv}[opts]} a shorthand \cmd{\tblfrkv{t}{csv}[naked_as_value=true,opts]}, a good way to convert  a comma-separated list to an array\\
- \cmd{\tblfrcsvN{t}{csv}[opts]} same as above, but the csv is not expanded.\\
+\cmd{\tblenforcechoices{i}{csv}} will throw an error if the value of item \cmd{i} is not in the provided \cmd{csv}
 
 
 \subsection*{Setting, getting, and modifying}
@@ -204,16 +209,23 @@
 
 \cmd{\tblif{i}{tr}[fa]} runs code \cmd{tr} if the item is true else \cmd{fa}\\
 \cmd{\tblifv{i}{tr}[fa]} runs code \cmd{tr} if the item is truth-y (using \cmd{pl.hasval}) else \cmd{fa}\\
-\cmd{\tblifeq{i}{v}{tr}[fa]} checks the equivalency of to a user-specified value. Quotes must be used to indicate strings.
+\cmd{\tblifeq{i}{v}{tr}[fa]} checks the equivalency of to a user-specified value.
+The value is fully expanded. Quotes must be used to indicate strings.\\
+\cmd{\tblifeqstr{i}{v}{tr}[fa]} checks the equivalency of to a user-specified value to a string (uses luastring).
 
 \begin{LTXexample}
+	\def\JJ{1}
 \tblfrcsv{x}{n=false,y=true,
-	k0="",kv=val,k2=6}
+	k0="",kv=val,k2=6,
+	k1=1,k11="1",
+}
 \tblif{n}{tr}[FA]\\
 \tblif{k0}{TR}[fa]\\
 \tblifv{k0}{tr}[FA]\\
 \tblifeq{kv}{'val'}{TR}[fa]\\
 \tblifeq{k2}{6}{TR}[fa]\\
+\tblifeq{k1}{\JJ}{Tr}
+\tblifeqstr{k11}{\JJ}{Tr}
 \end{LTXexample}
 
 
@@ -294,7 +306,7 @@
 
 
 \begin{LTXexample}
-	\tblfrkv{ex}{alen=1cm,blen=2cm,clen=10mm*2+2cm}[convert_dimensions]
+	\tblfrkv{ex}{alen=1cm,blen=2cm,clen=10mm*2+2cm}[convert_dimensions=true]
 	\tblmakelengths{}[<k>]
 	I\hspace{\alen}I\\
 	I\hspace{\blen}I\\

Modified: branches/branch2024.final/Master/texmf-dist/tex/lualatex/luatbls/luatbls.lua
===================================================================
--- branches/branch2024.final/Master/texmf-dist/tex/lualatex/luatbls/luatbls.lua	2025-02-15 21:32:40 UTC (rev 74020)
+++ branches/branch2024.final/Master/texmf-dist/tex/lualatex/luatbls/luatbls.lua	2025-02-15 21:32:48 UTC (rev 74021)
@@ -1,5 +1,5 @@
 --% Kale Ewasiuk (kalekje at gmail.com)
---% 2025-01-05
+--% 2025-02-14
 --% Copyright (C) 2025 Kale Ewasiuk
 --%
 --% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -150,6 +150,16 @@
     end
 end
 
+function luatbls._check_choices(k, csv)
+ local csv = penlight.List(luatbls._luakeys.parse(csv,{naked_as_value=true}))
+ local v = luatbls._get_tbl_item(k)
+    if not csv:contains(v) then
+        penlight.tex.pkgerror('luatbls', 'Invalid choice "'..v..'" given to tbl.key "'..k..'". Allowed choices are: '..
+        (', '):join(csv))
+    end
+end
+
+
 function luatbls._make_alpha_key(k)
      if tonumber(k) ~= nil then
          k = penlight.Char(tonumber(k))

Modified: branches/branch2024.final/Master/texmf-dist/tex/lualatex/luatbls/luatbls.sty
===================================================================
--- branches/branch2024.final/Master/texmf-dist/tex/lualatex/luatbls/luatbls.sty	2025-02-15 21:32:40 UTC (rev 74020)
+++ branches/branch2024.final/Master/texmf-dist/tex/lualatex/luatbls/luatbls.sty	2025-02-15 21:32:48 UTC (rev 74021)
@@ -1,5 +1,5 @@
 % Kale Ewasiuk (kalekje at gmail.com)
-% 2025-01-05
+% 2025-02-14
 % Copyright (C) 2025 Kale Ewasiuk
 %
 % Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -41,13 +41,13 @@
 }}
 
 \NewDocumentCommand{\tblfrkv}{m +m O{}}{\luadirect{% parse a tbl from key-vals, naked are set to boolean
-  luatbls._rec_tbl_opts = luatbls._luakeys.parse(\luastring{#3})
+  luatbls._rec_tbl_opts = luatbls._luakeys.parse(\luastring{#3}, {naked_as_value=true})
   luatbls[\luastring{#1}] = luatbls._luakeys.parse(string.subpar(\luastring{#2}), luatbls._rec_tbl_opts)
   luatbls._rec_tbl = \luastring{#1}
 }}
 
 \NewDocumentCommand{\tblfrkvN}{m +m O{}}{\luadirect{%
-  luatbls._rec_tbl_opts = luatbls._luakeys.parse(\luastring{#3})
+  luatbls._rec_tbl_opts = luatbls._luakeys.parse(\luastring{#3}, {naked_as_value=true})
   luatbls[\luastring{#1}] = luatbls._luakeys.parse(string.subpar(\luastringN{#2}), luatbls._rec_tbl_opts)
   luatbls._rec_tbl = \luastring{#1}
 }}
@@ -58,8 +58,11 @@
 
 \NewDocumentCommand{\tblkvundefcheck}{}{\luadirect{luatbls._check_recent_tbl_undefault()}}% check defaults list and throw error if foreign keys were used
 
+\NewDocumentCommand{\tblenforcechoices}{m m}{\luadirect{luatbls._check_choices(\luastring{#1},\luastring{#2})}}
 
 
+
+
 \NewDocumentCommand{\tblapp}{m m}{\luadirect{% append to a table (ie using integer index)  with a value (second arg)
   __tbl__ = luatbls._get_tbl_name(\luastring{#1})
   table.insert(luatbls[__tbl__], \luastring{#2})
@@ -134,20 +137,22 @@
 \NewDocumentCommand{\tblsetE}{m m}{\luadirect{luatbls.#1 = #2}}% set item with {value}
 
 
-\NewDocumentCommand{\tblif}{ m m O{}}{\ifluax{luatbls._get_tbl_item(\luastring{#1})}{#2}[#3]}
+\NewDocumentCommand{\tblif}{ m +m +O{}}{\ifluax{luatbls._get_tbl_item(\luastring{#1})}{#2}[#3]}
 
-\NewDocumentCommand{\tblifv}{m m O{}}{\ifluaxv{luatbls._get_tbl_item(\luastring{#1})}{#2}[#3]}
+\NewDocumentCommand{\tblifv}{m +m +O{}}{\ifluaxv{luatbls._get_tbl_item(\luastring{#1})}{#2}[#3]}
 
-\NewDocumentCommand{\tblifeq}{m m m O{}}{\ifluax{luatbls._get_tbl_item(\luastring{#1}) == #2}{#3}[#4]}
+\NewDocumentCommand{\tblifeq}{m m +m +O{}}{\ifluax{luatbls._get_tbl_item(\luastring{#1}) == \expanded{#2}}{#3}[#4]}
 
+\NewDocumentCommand{\tblifeqstr}{m m +m +O{}}{\ifluax{luatbls._get_tbl_item(\luastring{#1}) == \luastring{#2}}{#3}[#4]}
 
-\NewDocumentCommand{\tblfor}{  m m }{\luadirect{luatbls._for_tbl(\luastring{#1}, \luastring{#2})}}
-\NewDocumentCommand{\tblforN}{ m m }{\luadirect{luatbls._for_tbl(\luastring{#1}, \luastringN{#2})}}
 
-\NewDocumentCommand{\tblforE}{  m m }{\luadirect{luatbls._for_tbl_e(luatbls.#1, \luastring{#2})}}
-\NewDocumentCommand{\tblforEN}{ m m }{\luadirect{luatbls._for_tbl_e(luatbls.#1, \luastringN{#2})}}
+\NewDocumentCommand{\tblfor}{  m +m }{\luadirect{luatbls._for_tbl(\luastring{#1}, \luastring{#2})}}
+\NewDocumentCommand{\tblforN}{ m +m }{\luadirect{luatbls._for_tbl(\luastring{#1}, \luastringN{#2})}}
 
+\NewDocumentCommand{\tblforE}{  m +m }{\luadirect{luatbls._for_tbl_e(luatbls.#1, \luastring{#2})}}
+\NewDocumentCommand{\tblforEN}{ m +m }{\luadirect{luatbls._for_tbl_e(luatbls.#1, \luastringN{#2})}}
 
+
 \NewDocumentCommand{\tbldef}{  m o }{\luadirect{luatbls._def_tbl(\luastring{#1}, \luastring{#2})}}
 \NewDocumentCommand{\tblgdef}{ m o }{\luadirect{luatbls._def_tbl(\luastring{#1}, \luastring{#2}, 'global')}}
 
@@ -158,7 +163,6 @@
 
 \ProvideDocumentCommand{\providenewlength}{ m }{\ifdeflength{#1}{}{\newlength{#1}}}
 
-
 \NewDocumentCommand{\tblmaketoggle}{ m o }{\luadirect{luatbls._make_toggle_tbl(\luastring{#1}, \luastring{#2})}}
 \NewDocumentCommand{\tblmakegtoggle}{ m o }{\luadirect{luatbls._make_toggle_tbl(\luastring{#1}, \luastring{#2}, '\\global')}}
 



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