forked from ustctug/ustcthesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.lua
64 lines (50 loc) · 1.99 KB
/
build.lua
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env texlua
module = "ustcthesis"
testfiledir = "./test/testfiles"
testsuppdir = "./test/support"
demofiles = {"main.tex", "bib", "chapters"}
installfiles = {"*.cls", "*.bst", "*.bbx", "*.cbx", "figures"}
sourcefiles = {"*.cls", "*.bst", "*.bbx", "*.cbx", "figures"}
tagfiles = {"*.cls", "ustcthesis-doc.tex", "CHANGELOG.md", "main.tex"}
checkengines = {"xetex"}
stdengine = "xetex"
checkconfigs = {
"build",
"test/config-crossref",
"test/config-nomencl",
"test/config-bibtex",
"test/config-biblatex",
}
typesetexe = "xelatex"
unpackexe = "xetex"
checkopts = "-file-line-error -halt-on-error -interaction=nonstopmode"
typesetopts = "-file-line-error -halt-on-error -interaction=nonstopmode"
lvtext = ".tex"
function update_tag(file, content, tagname, tagdate)
tagname = string.gsub(tagname, "^v", "")
local url = "https://github.com/ustctug/ustcthesis"
local date = string.gsub(tagdate, "%-", "/")
content = string.gsub(content,
"Copyright %(C%) (%d%d%d%d)%-%d%d%d%d",
"Copyright (C) %1-" .. os.date("%Y"))
if string.match(file, "%.cls$") then
content = string.gsub(content, "\\newcommand\\ustcthesisversion{[0-9.]+",
"\\newcommand\\ustcthesisversion{" .. tagname)
content = string.gsub(content, "\\ProvidesClass{ustcthesis}%[%d%d%d%d/%d%d/%d%d",
"\\ProvidesClass{ustcthesis}[" .. date)
elseif string.match(file, "%-doc.tex") then
content = string.gsub(content, "v[0-9.]+\\qquad %d%d%d%d%-%d%d%-%d%d",
"v" .. tagname .. "\\qquad " .. tagdate)
elseif string.match(file, "CHANGELOG.md") then
local previous = string.match(content, "/compare/v(.*)%.%.%.HEAD")
if tagname == previous then return content end
content = string.gsub(content,
"## %[Unreleased%]",
"## [Unreleased]\n\n## [" .. tagname .."] - " .. tagdate)
content = string.gsub(content,
previous .. "%.%.%.HEAD",
tagname .. "...HEAD\n[" .. tagname .. "]: " .. url .. "/compare/v"
.. previous .. "...v" .. tagname)
end
return content
end