summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/gitinfo-lua/scripts/gitinfo-lua.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/latex/gitinfo-lua/scripts/gitinfo-lua.lua')
-rw-r--r--macros/luatex/latex/gitinfo-lua/scripts/gitinfo-lua.lua21
1 files changed, 11 insertions, 10 deletions
diff --git a/macros/luatex/latex/gitinfo-lua/scripts/gitinfo-lua.lua b/macros/luatex/latex/gitinfo-lua/scripts/gitinfo-lua.lua
index 4cb0f0f467..a1c2a6988b 100644
--- a/macros/luatex/latex/gitinfo-lua/scripts/gitinfo-lua.lua
+++ b/macros/luatex/latex/gitinfo-lua/scripts/gitinfo-lua.lua
@@ -23,9 +23,10 @@ end
local module = {
name = 'gitinfo-lua',
info = {
- version = 1.0,
+ version = '1.0.1', --TAGVERSION
+ date = '2024/02/12', --TAGDATE
comment = "Git info Lua — Git integration with LaTeX",
- author = "Erik Nijenhuis",
+ author = "Erik Nijenhuis",
license = "free"
}
}
@@ -43,8 +44,8 @@ local api = {
['_'] = '\\_',
['{'] = '\\{',
['}'] = '\\}',
- ['~'] = '\\textasciitilde',
- ['%^'] = '\\textasciicircum'
+ ['~'] = '\\textasciitilde ',
+ ['%^'] = '\\textasciicircum '
}
}
local mt = {
@@ -55,11 +56,11 @@ local gitinfo = {}
setmetatable(gitinfo, mt)
function api.trim(s)
- return (s:gsub("^%s*(.-)%s*$", "%1"))
+ return s and (s:gsub("^%s*(.-)%s*$", "%1")) or 'nil'
end
function api:set_date()
- local date, err = self.cmd:log('cs', '-1', {'max-count=1'})
+ local date, err = self.cmd:log('cs', '-1', { 'max-count=1' })
if date and #date == 1 then
local _, _, year, month, day = date[1][1]:find('(%d+)[-/](%d+)[-/](%d+)')
tex.year = tonumber(year)
@@ -71,7 +72,7 @@ function api:set_date()
end
function api:escape_str(value)
- local buf = string.gsub(value, '\\', '\\textbackslash')
+ local buf = string.gsub(value, '\\', '\\textbackslash ')
for search, replace in pairs(self.escape_chars) do
buf = string.gsub(buf, search, replace)
end
@@ -223,7 +224,7 @@ end
function api:cs_commit(csname, rev, format)
if token.is_defined(csname) then
local tok = token.create(csname)
- local log, err = self.cmd:log(format, rev, {'max-count=1'})
+ local log, err = self.cmd:log(format, rev, { 'max-count=1' })
if log then
if #log == 1 then
tex.print(tok)
@@ -266,7 +267,7 @@ end
function api:tag_info(format_spec, tag, target_dir)
local err, info
- info, err = self.cmd:for_each_ref(format_spec, 'refs/tags', {'count=1', 'contains=' .. tag}, target_dir)
+ info, err = self.cmd:for_each_ref(format_spec, 'refs/tags', { 'count=1', 'contains=' .. tag }, target_dir)
if info and #info == 1 then
return info[1]
else
@@ -305,7 +306,7 @@ end
function api:cs_for_tag(csname, format_spec, target_dir)
if token.is_defined(csname) then
local tok = token.create(csname)
- local tags, err = self.cmd:for_each_ref(format_spec, 'refs/tags', {'sort=-authordate'}, target_dir)
+ local tags, err = self.cmd:for_each_ref(format_spec, 'refs/tags', { 'sort=-authordate' }, target_dir)
if tags then
for _, info in ipairs(tags) do
tex.print(tok)