Repository navigation
Expand file tree
/
Copy pathbuild.lua
More file actions
39 lines (37 loc) · 1.6 KB
/
Copy pathbuild.lua
File metadata and controls
39 lines (37 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module = 'lua-unicode-math'
tdsroot = 'lualatex'
typesetexe = 'lualatex'
unpackexe = 'luatex'
unpackfiles = {'*.ins'}
installfiles = {'*.sty', 'lua-unicode-math*.lua', '*.fd'}
sourcefiles = {'*.dtx', '*.ins', '*.lua', '*.fd', '*.sty'}
textfiles = {'README.md'}
checkengines = {'luatex'}
tagfiles = {'*.dtx', '*.lua'}
function update_tag(file, content, tagname, tagdate)
local tagyear = tagdate:sub(1, 4)
local year = '2' * lpeg.R'09' * lpeg.R'09' * lpeg.R'09'
local date = year * '-' * lpeg.R'09' * lpeg.R'09' * '-' * lpeg.R'09' * lpeg.R'09'
local ws = lpeg.S' \t\n\r'^0
if file:sub(-4) == '.dtx' then
content = lpeg.Cs((
lpeg.P"% Copyright (C) " * (
year * '-' * lpeg.Cg(year * lpeg.Cc(tagyear))
+ year / function(oldyear) return oldyear == tostring(tagyear) and oldyear or string.format('%s-%s', oldyear, tagyear) end
)
+ '\\ProvidesExplPackage' * ws * '{' * (1 - lpeg.P'}')^0 * '}' * ws * '{' * ws * lpeg.Cg(date * lpeg.Cc(tagdate)) * ws * '}' * ws * '{' * lpeg.Cg((1 - lpeg.P'}')^0 * lpeg.Cc(tagname)) * '}'
+ 1
)^0 * -1):match(content)
elseif file:sub(-4) == '.lua' then
content = lpeg.Cs((
lpeg.P"-- Copyright (C) " * (
year * '-' * lpeg.Cg(year * lpeg.Cc(tagyear))
+ year / function(oldyear) return oldyear == tostring(tagyear) and oldyear or string.format('%s-%s', oldyear, tagyear) end
)
+ 'local date = \'' * lpeg.Cg(date * lpeg.Cc(tagdate)) * '\'' * #lpeg.P'\n'
+ 'local version = \'v' * lpeg.Cg((1 - lpeg.P'\'')^0 * lpeg.Cc(tagname)) * '\'' * #lpeg.P'\n'
+ 1
)^0 * -1):match(content)
end
return content
end