diff options
author | Karl Berry <karl@freefriends.org> | 2024-02-21 21:10:30 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-02-21 21:10:30 +0000 |
commit | e06c48a0936bdf0224fe8fd12d6e177e9a9ca6aa (patch) | |
tree | a4766710c50ccf5788ed18f3c9b5803cfa544ac0 /Master/texmf-dist/scripts | |
parent | 60f3bd5d1ac0ae4dbcc1d6e9ff079bb31023e862 (diff) |
lua-placeholders (21feb24)
git-svn-id: svn://tug.org/texlive/trunk@70048 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
3 files changed, 23 insertions, 8 deletions
diff --git a/Master/texmf-dist/scripts/lua-placeholders/lua-placeholders-parser.lua b/Master/texmf-dist/scripts/lua-placeholders/lua-placeholders-parser.lua index 3583c09a28e..4a0304c4636 100644 --- a/Master/texmf-dist/scripts/lua-placeholders/lua-placeholders-parser.lua +++ b/Master/texmf-dist/scripts/lua-placeholders/lua-placeholders-parser.lua @@ -32,7 +32,7 @@ end local current_path = os.getenv('LUA_PATH') if current_path then texio.write_nl('Info: LUA path setup up correctly. Great job!') -else +elseif not tiny_found then -- Set the LUA_PATH and LUA_CPATH using 'luarocks -lua-version <LuaLaTeX version> path' texio.write_nl('Warning: No LUA_PATH set. Looking for LuaRocks installation...') local handle = io.popen('luarocks --lua-version ' .. LUA_VERSION .. ' path') @@ -60,6 +60,8 @@ else else tex.error('Error: could not open a shell. Is shell-escape turned on?') end +else + texio.write_nl('Warning: no LUA_PATH set.') end texio.write_nl('\n') diff --git a/Master/texmf-dist/scripts/lua-placeholders/lua-placeholders-types.lua b/Master/texmf-dist/scripts/lua-placeholders/lua-placeholders-types.lua index bb6abafdb18..d640de626c8 100644 --- a/Master/texmf-dist/scripts/lua-placeholders/lua-placeholders-types.lua +++ b/Master/texmf-dist/scripts/lua-placeholders/lua-placeholders-types.lua @@ -104,13 +104,22 @@ str_param = base_param:new{ function str_param:new(key, _o) local o = { key = key, - placeholder = _o.placeholder + placeholder = _o.placeholder, + default = _o.default } setmetatable(o, self) self.__index = self return o end +function str_param:val() + local value = self:raw_val() + if value then + local formatted, _ = string.gsub(value, '\n', ' ') + return formatted + end +end + number_param = base_param:new{ type = 'number' } @@ -127,14 +136,14 @@ function number_param:new(key, _o) end function number_param:raw_val() - if self.value or self.default then + if self.value ~= nil or self.default ~= nil then return self.value or self.default end end function number_param:val() local val = self:raw_val() - if val then + if val ~= nil then if token.is_defined('numprint') then return '\\numprint{' .. val .. '}' else diff --git a/Master/texmf-dist/scripts/lua-placeholders/lua-placeholders.lua b/Master/texmf-dist/scripts/lua-placeholders/lua-placeholders.lua index 832e0106eb2..24f0a6c5ca2 100644 --- a/Master/texmf-dist/scripts/lua-placeholders/lua-placeholders.lua +++ b/Master/texmf-dist/scripts/lua-placeholders/lua-placeholders.lua @@ -23,9 +23,9 @@ if not modules then end modules.lua_placeholders = { - version = "1.0.1", - date = "2024/02/12", - comment = 'Extended LaTeX Parameter Interface — for specifying and inserting document parameters', + version = "1.0.2", + date = "2024/02/21", + comment = 'Lua Placeholders — for specifying and inserting document parameters', author = 'Erik Nijenhuis', license = 'free' } @@ -200,7 +200,11 @@ function api.with_rows(key, namespace, csname) texio.write_nl("Warning: no values set for " .. param.key) local format = row_content for col_key, col in pairs(param.columns) do - format = format:gsub('\\' .. col_key, '{\\paramplaceholder{' .. (col.placeholder or col_key) .. '}}') + if col.default ~= nil then + format = format:gsub('\\' .. col_key, col:val()) + else + format = format:gsub('\\' .. col_key, '{\\paramplaceholder{' .. (col.placeholder or col_key) .. '}}') + end end tex.print(format) else |