Skip to content

Commit

Permalink
Merge branch 'master' into ci-build
Browse files Browse the repository at this point in the history
  • Loading branch information
MacLotsen committed Feb 21, 2024
2 parents edcb4d5 + 098f9bd commit 85aea5b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 17 deletions.
27 changes: 17 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
CONTRIBUTION = "lua-placeholders-$(shell git describe --tags --always).tar.gz"
PACKAGE_DIR = $(shell pwd)
CNF_LINE = -cnf-line TEXMFHOME={$(PACKAGE_DIR),$(shell kpsewhich --var-value TEXMFHOME)}
COMPILE = lualatex --interaction=nonstopmode --shell-escape $(CNF_LINE)
RM = rm
ifeq ($(OS),Windows_NT)
RM = del
endif

retry: clean-all build clean

Expand All @@ -9,25 +16,25 @@ package: $(CONTRIBUTION)
build: doc/lua-placeholders-manual.pdf

clean:
cd doc && latexmk -c 2> /dev/null && rm -f *.atfi *.bbl *.run.xml
cd doc/lua-placeholders-example && latexmk -c 2> /dev/null
cd doc && latexmk -c lua-placeholders-manual 2> /dev/null && $(RM) -f *.atfi *.bbl *.run.xml
cd doc/lua-placeholders-example && latexmk -c example 2> /dev/null

clean-all:
cd doc && latexmk -C 2> /dev/null && rm -f *.atfi *.bbl *.run.xml
cd doc/lua-placeholders-example && latexmk -C 2> /dev/null
cd doc && latexmk -C lua-placeholders-manual 2> /dev/null && $(RM) -f *.atfi *.bbl *.run.xml
cd doc/lua-placeholders-example && latexmk -C example 2> /dev/null

doc/lua-placeholders-example/example.pdf: doc/lua-placeholders-example/example.tex tex/lua-placeholders.sty scripts/$(wildcard *.lua)
doc/lua-placeholders-example/example.pdf: doc/lua-placeholders-example/example.tex tex/lua-placeholders.sty $(wildcard scripts/*.lua)
@echo "Creating example PDF"
cd doc/lua-placeholders-example && \
lualatex --interaction=nonstopmode --shell-escape example > /dev/null
$(COMPILE) example

doc/lua-placeholders-manual.pdf: doc/lua-placeholders-example/example.pdf doc/lua-placeholders-manual.tex tex/lua-placeholders.sty scripts/$(wildcard *.lua)
doc/lua-placeholders-manual.pdf: doc/lua-placeholders-example/example.pdf doc/lua-placeholders-manual.tex tex/lua-placeholders.sty $(wildcard scripts/*.lua)
@echo "Creating documentation PDF"
cd doc && \
lualatex --interaction=nonstopmode --shell-escape lua-placeholders-manual && \
$(COMPILE) lua-placeholders-manual && \
biber lua-placeholders-manual && \
lualatex --interaction=nonstopmode --shell-escape lua-placeholders-manual && \
lualatex --interaction=nonstopmode --shell-escape lua-placeholders-manual
$(COMPILE) lua-placeholders-manual && \
$(COMPILE) lua-placeholders-manual

$(CONTRIBUTION): doc/lua-placeholders-manual.pdf clean
@echo "Creating package tarball"
Expand Down
2 changes: 1 addition & 1 deletion doc/lua-placeholders-example/example.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

\documentclass{article}
\usepackage{gitinfo-lua}
\usepackage{../../tex/lua-placeholders}
\usepackage{lua-placeholders}
\usepackage{listings}
\usepackage{amsmath}
\usepackage{calc}
Expand Down
2 changes: 1 addition & 1 deletion doc/lua-placeholders-manual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@

\clearpage

\section{Changelog}
\section{Change Log}
\newcommand\commitline[3]{\item #1\ifx&#3&%
\else\\[1em]
#3\fi\\\hspace*{1em} — \printdate{#2}}
Expand Down
4 changes: 3 additions & 1 deletion scripts/lua-placeholders-parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')

Expand Down
15 changes: 12 additions & 3 deletions scripts/lua-placeholders-types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion scripts/lua-placeholders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 85aea5b

Please sign in to comment.