@@ -421,29 +421,43 @@ end
421421
422422function CslEngine :_layout (options , content , entries )
423423 local output = {}
424+ if self .mode == " citation" then
425+ for _ , entry in ipairs (entries ) do
426+ self :_prerender ()
427+ local elem = self :_render_children (content , entry )
428+ elem = self :_postrender (elem )
429+ if elem then
430+ table.insert (output , elem )
431+ end
432+ end
433+ -- The CSL 1.0.2 specification is not very clear on this point, but on
434+ -- citations, affixes and formatting apply on the whole layout.
435+ -- Affixes are arround the delimited list, e.g. "(Smith, 2000; Jones, 2001)"
436+ -- Rendering is done after, so vertical-align, etc. apply to the whole list,
437+ -- e.g. <textsuperscript>1,2</textsuperscript>
438+ local cites = self :_render_delimiter (output , options .delimiter or " ; " )
439+ cites = self :_render_affixes (cites , options )
440+ cites = self :_render_formatting (cites , options )
441+ return cites
442+ end
443+ -- On bibliographies, affixes (usually just a period suffix) apply on each entry.
444+ -- Formatting is not forbidden in the specification, and occurs in a few styles.
445+ -- But it doesn't seem to be very useful (mostly font-variant="normal" and
446+ -- vertical-align="baseline"). Anyhow, if set, it probably applies to the
447+ -- entry including the affixes.
448+ -- CSL 1.0.2 only mentions a delimiter for citations, so it's not used here,
449+ -- quite logically as we force a paragraph break between entries.
424450 for _ , entry in ipairs (entries ) do
425451 self :_prerender ()
426452 local elem = self :_render_children (content , entry )
427- -- affixes and formatting likely apply on elementary entries
428- -- (The CSL 1.0.2 specification is not very clear on this point.)
429- elem = self :_render_formatting (elem , options )
430453 elem = self :_render_affixes (elem , options )
454+ elem = self :_render_formatting (elem , options )
431455 elem = self :_postrender (elem )
432456 if elem then
433457 table.insert (output , elem )
434458 end
435459 end
436- if options .delimiter then
437- return self :_render_delimiter (output , options .delimiter )
438- end
439- -- (Normally citations have a delimiter options, so we should only reach
440- -- this point for the bibliography)
441- local delim = self .mode == " citation" and " ; " or " <par/>"
442- -- references all belong to a different paragraph
443- -- FIXME: should account for attributes on the toplevel bibliography element:
444- -- line-spacing
445- -- hanging-indent
446- return table.concat (output , delim )
460+ return table.concat (output , " <par/>" )
447461end
448462
449463function CslEngine :_text (options , content , entry )
0 commit comments