Search code examples
luapandocquarto

How to run a lua filter in Quarto after the crossreferences were added?


I am trying to write a lua filter which works on figure caption titles, i.e. stuff like "Figure 1" in the figure caption. See this question for background. Basically I want to make this "Figure 1" part in bold (including figure number).

However, it appears that when Quarto runs a lua filter the caption of the Image object in AST does not yet contain the figure title; the caption at this stage is [ Str "Your", Space, Str "Caption" ], whereas after Quarto is done (and you convert the output to native, for example) it becomes [ Str "Figure", Str "\160", Str "1", Str ":", Space, "Your", Space, Str "Caption" ].

My question: is there a way of running a lua filter in quarto after the cross-references and caption titles have been added?


Solution

  • Quarto supports quarto as a special specifier in the filter list, which allows to set the position of the default Quarto filters relative to other filters:

    ---
    filters:
      - run-me-first.lua
      - quarto
      - my-figure-modifier.lua
    ---