summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/penlightplus/penlightplus.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/generic/penlightplus/penlightplus.sty')
-rw-r--r--macros/luatex/generic/penlightplus/penlightplus.sty26
1 files changed, 20 insertions, 6 deletions
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')
}}