Enforcing the filter order with a custom format #6747
-
DescriptionI'm writing a custom format which uses a custom filter. This generally works okay, but I've noticed that my filter is definitely running before the Quarto filters, which contradicts what the docs say. Is that a mistake? In any case, I want to force my filter to run after Quarto, because my filter needs to modify the Quarto-generated content. This works in the document YAML if I do something like this: format:
my-format-docx:
filters:
- quarto
- my_extension.lua However, I'm making a custom format I want to distribute. If in my title: my-extension
author: Michael Milton
version: 1.0.0
quarto-required: ">=1.3.0"
contributes:
filters:
- my_extension.lua
formats:
common:
filters:
- quarto
- my-extension.lua
Is this a bug? Is there a recommended way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I think you're confusing two slightly different notions: that of declaring the use filter in a document, and that of declaring which filters are exposed by an extension. The former (declaring the use filter in a document) allows you to control the order in which this happens, but needs to be done at the point of use of the filter (or extension). This is by design, because the ordering of the filters matters most often when different filters are combined, and there's no mechanism for filters to declare their "preferred order" for what other filters. The latter (declaring which filters are exposed by an extension) has no mechanism for specifying the filter order relative to quarto's filters. In this situation you can only declare the order of the internal filters of your own extension, and those are then fixed. The recommended way to do this is to document whether your filter needs to happen before or after quarto, and then the filter user needs to specify that in their usage. That's (understandably) unwieldy, but it's unfortunately the best design we arrived at. |
Beta Was this translation helpful? Give feedback.
Tracking in #6759.