@@ -140,99 +140,96 @@ local kAffiliationAliasedFields = {
140140-- a simple incremental counter that can be used for things like note numbers
141141local kNumber = " number"
142142
143- -- Normalizes author metadata from the 'input' field into
144- -- consistently structured metadata in the 'output' field
145- function authorsMeta ()
146- return {
147- Meta = function (meta )
148- if not _quarto .format .isHtmlOutput () and not _quarto .format .isLatexOutput () and not _quarto .format .isIpynbOutput () then
149- return
150- end
143+ function processAuthorMeta (meta , authorInput )
144+ if not _quarto .format .isHtmlOutput () and not _quarto .format .isLatexOutput () and not _quarto .format .isIpynbOutput () then
145+ return
146+ end
151147
152- local authorsRaw = meta [kAuthorInput ]
153-
154- -- the normalized authors
155- local authors = {}
156-
157- -- the normalized affilations
158- local affiliations = {}
159-
160- if authorsRaw then
161- for i ,v in ipairs (authorsRaw ) do
162-
163- local authorAndAffiliations = processAuthor (v )
164-
165- -- initialize the author
166- local author = authorAndAffiliations .author
167- local authorAffils = authorAndAffiliations .affiliations
168-
169- -- assign an id to this author if one isn't defined
170- local authorNumber = # authors + 1
171- if author [kId ] == nil then
172- author [kId ] = authorNumber
173- end
174-
175- -- go through the affilations and add any to the list
176- -- assigning an id if needed
177- if authorAffils ~= nil then
178- for i ,v in ipairs (authorAffils ) do
179- local affiliation = maybeAddAffiliation (v , affiliations )
180- setAffiliation (author , { ref = affiliation [kId ] })
181- end
182- end
148+ if authorInput == nil then
149+ authorInput = kAuthorInput
150+ end
151+ local authorsRaw = meta [authorInput ]
152+
153+ -- the normalized authors
154+ local authors = {}
183155
184- -- add this author to the list of authors
185- authors [authorNumber ] = author
186- end
187- end
156+ -- the normalized affilations
157+ local affiliations = {}
188158
189- -- Add any attributes that are explicitly specified
190- local affiliationsRaw = meta [kAffiliations ]
191- if affiliationsRaw then
192- local explicitAffils = processAffiliation (nil , affiliationsRaw )
193- if explicitAffils then
194- for i ,affiliation in ipairs (explicitAffils ) do
195- maybeAddAffiliation (affiliation , affiliations )
196- end
159+ if authorsRaw then
160+ for i ,v in ipairs (authorsRaw ) do
161+
162+ local authorAndAffiliations = processAuthor (v )
163+
164+ -- initialize the author
165+ local author = authorAndAffiliations .author
166+ local authorAffils = authorAndAffiliations .affiliations
167+
168+ -- assign an id to this author if one isn't defined
169+ local authorNumber = # authors + 1
170+ if author [kId ] == nil then
171+ author [kId ] = authorNumber
172+ end
173+
174+ -- go through the affilations and add any to the list
175+ -- assigning an id if needed
176+ if authorAffils ~= nil then
177+ for i ,v in ipairs (authorAffils ) do
178+ local affiliation = maybeAddAffiliation (v , affiliations )
179+ setAffiliation (author , { ref = affiliation [kId ] })
197180 end
198181 end
199182
200- -- validate that every author affiliation has a corresponding
201- -- affiliation defined in the affiliations key
202- validateRefs (authors , affiliations )
183+ -- add this author to the list of authors
184+ authors [authorNumber ] = author
185+ end
186+ end
203187
204- -- number the authors and affiliations
205- for i ,affil in ipairs (affiliations ) do
206- affil [kNumber ] = i
207- end
208- for i ,auth in ipairs (authors ) do
209- auth [kNumber ] = i
188+ -- Add any attributes that are explicitly specified
189+ local affiliationsRaw = meta [kAffiliations ]
190+ if affiliationsRaw then
191+ local explicitAffils = processAffiliation (nil , affiliationsRaw )
192+ if explicitAffils then
193+ for i ,affiliation in ipairs (explicitAffils ) do
194+ maybeAddAffiliation (affiliation , affiliations )
210195 end
196+ end
197+ end
211198
212- -- Write the normalized data back to metadata
213- if # authors ~= 0 then
214- meta [kAuthorOutput ] = authors
215- end
199+ -- validate that every author affiliation has a corresponding
200+ -- affiliation defined in the affiliations key
201+ validateRefs (authors , affiliations )
216202
217- if # affiliations ~= 0 then
218- meta [kAffiliations ] = affiliations
219- end
203+ -- number the authors and affiliations
204+ for i ,affil in ipairs (affiliations ) do
205+ affil [kNumber ] = i
206+ end
207+ for i ,auth in ipairs (authors ) do
208+ auth [kNumber ] = i
209+ end
220210
221- -- Write the de- normalized versions back to metadata
222- if # authors ~= 0 then
223- meta [kByAuthor ] = byAuthors ( authors , affiliations )
224- end
211+ -- Write the normalized data back to metadata
212+ if # authors ~= 0 then
213+ meta [kAuthorOutput ] = authors
214+ end
225215
226- if # affiliations ~= 0 then
227- meta [kByAffiliation ] = byAffiliations ( authors , affiliations )
228- end
216+ if # affiliations ~= 0 then
217+ meta [kAffiliations ] = affiliations
218+ end
229219
230- -- Provide localized or user specified strings for title block elements
231- meta = computeLabels (authors , affiliations , meta )
220+ -- Write the de-normalized versions back to metadata
221+ if # authors ~= 0 then
222+ meta [kByAuthor ] = byAuthors (authors , affiliations )
223+ end
232224
233- return meta
234- end
235- }
225+ if # affiliations ~= 0 then
226+ meta [kByAffiliation ] = byAffiliations (authors , affiliations )
227+ end
228+
229+ -- Provide localized or user specified strings for title block elements
230+ meta = computeLabels (authors , affiliations , meta )
231+
232+ return meta
236233end
237234
238235-- Add an affiliation to the list of affiliations if needed
0 commit comments