@@ -108,6 +108,10 @@ export function removeFilterParmas(metadata: Metadata) {
108108 delete metadata [ kQuartoParams ] ;
109109}
110110
111+ export function quartoInitFilter ( ) {
112+ return resourcePath ( "filters/quarto-init/quarto-init.lua" ) ;
113+ }
114+
111115export function quartoPreFilter ( ) {
112116 return resourcePath ( "filters/quarto-pre/quarto-pre.lua" ) ;
113117}
@@ -491,14 +495,21 @@ export function resolveFilters(
491495 options : PandocOptions ,
492496) : QuartoFilter [ ] | undefined {
493497 // build list of quarto filters
498+
499+ // The default order of filters will be
500+ // quarto-init
501+ // quarto-authors
502+ // user filters
503+ // extension filters
504+ // quarto-filters <quarto>
505+ // citeproc
506+ // quarto-finalizer
507+
494508 const quartoFilters : string [ ] = [ ] ;
495509 quartoFilters . push ( quartoPreFilter ( ) ) ;
496510 if ( crossrefFilterActive ( options ) ) {
497511 quartoFilters . push ( crossrefFilter ( ) ) ;
498512 }
499- if ( authorsFilterActive ( options ) ) {
500- quartoFilters . push ( authorsFilter ( ) ) ;
501- }
502513 quartoFilters . push ( layoutFilter ( ) ) ;
503514 quartoFilters . push ( quartoPostFilter ( ) ) ;
504515
@@ -519,19 +530,27 @@ export function resolveFilters(
519530 ...filters . slice ( quartoLoc + 1 ) ,
520531 ] ;
521532 } else {
522- filters . unshift ( ...quartoFilters ) ;
533+ filters . push ( ...quartoFilters ) ;
534+ }
535+
536+ // The author filter, if enabled
537+ if ( authorsFilterActive ( options ) ) {
538+ filters . unshift ( authorsFilter ( ) ) ;
523539 }
524540
541+ // The initializer for Quarto
542+ filters . unshift ( quartoInitFilter ( ) ) ;
543+
544+ // The finalizer for Quarto
545+ filters . push ( quartoFinalizeFilter ( ) ) ;
546+
525547 // citeproc at the very end so all other filters can interact with citations
526548 filters = filters . filter ( ( filter ) => filter !== "citeproc" ) ;
527549 const citeproc = citeMethod ( options ) === "citeproc" ;
528550 if ( citeproc ) {
529551 filters . push ( "citeproc" ) ;
530552 }
531553
532- // The finalizer for Quarto
533- filters . push ( quartoFinalizeFilter ( ) ) ;
534-
535554 // return filters
536555 if ( filters . length > 0 ) {
537556 return filters ;
0 commit comments