@@ -73,16 +73,22 @@ local roles = {
7373 }
7474}
7575
76+ -- An enumeration of the JATS-recommended degrees of contribution
7677degrees = pandoc .List {
7778 " Lead" ,
7879 " Supporting" ,
7980 " Equal"
8081}
8182
82- function invalidRole (str )
83+ -- Check if the given string is one of the 14 valid
84+ -- CRediT identifiers by looking at the `roles` dict
85+ -- defined above
86+ function invalidCreditID (str )
8387 return roles [str ] == nil
8488end
8589
90+ -- Check if the degree contribution is valid based on the JATS recommendation,
91+ -- see https://jats.taylorandfrancis.com/jats-guide/topics/author-contributions-credit/#degree-of-contribution
8692function invalidDegree (str )
8793 return not degrees :includes (str )
8894end
@@ -105,6 +111,9 @@ function capitalize_first_letter(str)
105111 return str :sub (1 , 1 ):upper () .. str :sub (2 )
106112end
107113
114+ -- If the data is just a string corresponding to a
115+ -- CRediT identifier, upgrade it to a dictionary,
116+ -- otherwise return it as is
108117function clean_role_dict (d )
109118 if d .credit then
110119 return d
@@ -121,7 +130,7 @@ local function prepare_credit (meta)
121130 for _ , roleDict in ipairs (author .roles ) do
122131 roleDict = clean_role_dict (roleDict )
123132 credit_id = pandoc .utils .stringify (roleDict .credit )
124- if invalidRole (credit_id ) then
133+ if invalidCreditID (credit_id ) then
125134 print (" invalid credit ID for author " .. author .name .. " : " .. credit_id )
126135 elseif roleDict .degree then
127136 degree = capitalize_first_letter (pandoc .utils .stringify (roleDict .degree ))
0 commit comments