-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpandoc-gls.lua
53 lines (46 loc) · 1.48 KB
/
pandoc-gls.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
function replace(front, ac, back, command)
new_str = string.format("%s\\%s{%s}%s", front, command, ac, back)
return new_str
end
function Str(el)
front, capital, plural, ac, apostrophe, back = el.text:match(
"(%g*)%(([%+%-]+)(%^-)(%w+[_%-]*%w*)%)([%\u{0027}%\u{2019}]*)(%g*)"
)
if ac ~= "" then
if plural == "^" then
if capital == "++" then
command = "Glspl"
elseif capital == "+" then
command = "glspl"
elseif capital == "-+" then
command = "Glsentryplural"
elseif capital == "-" then
command = "glsentryplural"
else
-- Unknown command string so just return the element unchanged
return el
end
else
if capital == "++" then
command = "Gls"
elseif capital == "+" then
command = "gls"
elseif capital == "-+" then
command = "Glsentryname"
elseif capital == "-" then
command = "glsentryname"
else
-- Unknown command string so just return the element unchanged
return el
end
end
if apostrophe == "\u{0027}" or apostrophe == "\u{2019}" then
if back ~= "" then
back = string.format("'%s", back)
else
back = "\\textquotesingle\\space"
end
end
return pandoc.RawInline("tex", replace(front, ac, back, command))
end
end