forked from openjournals/inara
-
Notifications
You must be signed in to change notification settings - Fork 1
/
neurolibre-handle-crowd.lua
73 lines (61 loc) · 2.1 KB
/
neurolibre-handle-crowd.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
65
66
67
68
69
70
71
72
73
local stringify = pandoc.utils.stringify
function CountAuthors(meta)
if meta['author'] then
-- Check if there is a single author or multiple authors
if type(meta['author']) == 'table' then
num_authors = #meta['author']
else
num_authors = 1
end
end
return num_authors
end
function joinTableToString(table)
-- Check if the table is empty
if #table == 0 then
return ""
end
-- Initialize an empty string to hold the joined elements
local joinedString = stringify(table[1])
-- Iterate over the elements of the table and concatenate them with commas and spaces
for i = 2, #table do
joinedString = joinedString .. ", " .. stringify(table[i])
end
return joinedString
end
--- Removes and alters metadata for draft output
function Meta (meta)
local authors = meta['author']
local authorString = ""
for i, author in ipairs(authors) do
if author['equal-contrib'] then
authorString = authorString .. "*"
end
authorString = authorString .. "{\\Authfont " .. author.name .. "}"
-- authorString = authorString .. author.name
for j, affiliation in ipairs(author.affiliation) do
authorString = authorString .. "\\textsuperscript{" .. affiliation .. "}"
if j < #author.affiliation then
authorString = authorString .. "\\textsuperscript{,}"
end
end
if i < #authors then
authorString = authorString .. ", "
end
end
local affiliations = meta.affiliations
local affiliationString = ""
for i, aff in ipairs(affiliations) do
-- affiliationString = affiliationString .. i .. tmp .. "\n"
affiliationString = affiliationString .. " {\\bfseries " .. stringify(i) .. "}\\hspace{3pt} " .. stringify(aff.name)
-- if i < #affiliations then
-- affiliationString = affiliationString .. "\n"
-- end
end
meta.affiliationsList = pandoc.RawInline("latex",affiliationString)
meta.authorsWithAffiliations = pandoc.RawInline("latex",authorString)
-- Check if there are more than 10 authors
meta.moreThanTenAuthors = #authors > 10
meta.noMoreThanTenAuthors = #authors <= 10
return meta
end