generic pre-processor mechanism #3150
Replies: 5 comments 14 replies
-
I think you are describing a Lua filter here (see https://quarto.org/docs/extensions/filters.html). Regarding the part about Pollen, the examples do not seem different from what you can already do in Quarto/Pandoc, i.e., you can use fenced divs to inject any HTML/CSS attributes, and you can use SASS/SCSS to modify globally some values. The part about macros from another of your issue lacks actual reproducible example for someone to really help. |
Beta Was this translation helpful? Give feedback.
-
Interestingly, pandoc itself could be used as a pre-processor, using a custom writer that would be doing (almost) a no-op between the original qmd and the intermediate qmd. The advantage is that pandoc's AST provides a more structured entry point to make strategic changes into the document, compared to, say, a regex approach. For example, |
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback. We're designing something analogous to this. The problem is complicated by the fact that we take both .qmd and .ipynb as input formats, and we're aiming for feature parity across those code paths (even though we'll probably never achieve it fully). |
Beta Was this translation helpful? Give feedback.
-
See https://quarto.org/docs/projects/scripts.html#pre-and-post-render. |
Beta Was this translation helpful? Give feedback.
-
Just adding a note here that, in addition to a |
Beta Was this translation helpful? Give feedback.
-
I'm thinking it would be nice to be able to pre-process
qmd
files into an intermediate, temporaryqmd
that gets processed by Quarto. This is different from pre-render scripts, in that theqmd
file itself is being processed, but shouldn't be overwritten (otherwise we lose access to the true original source). Maybe it's possible to hack pre-render scripts in some way (creating a newqmd
file, and somehow redirecting Quarto to it), but I'm thinking of something a bit more robust/intentional.What could be the use-case?
qmd
has its own syntax limitations, and there are cases where a more ad-hoc syntax would be preferable, for a specific purpose. For example, Pollen introduces some ideas that go beyond markdown-type markups, such as defining arbitrarily-programmable macros on-the-fly with unobtrusive syntax ◊macro{}.Another use-case might be to pre-process all LaTeX macros.
One could also inject arbitrary content into
qmd
files, including other files, etc. beyond the limitations of<< include >>
, which don't work everywhere (e.g. in some Yaml fields, etc.).On the topic of Yaml, this is also potentially a way to work around some limitations of Yaml: the original source could have ad-hoc syntax, convenient for the user, which gets transformed into valid Yaml (e.g. escaping all backslashes... – who wants to do this by hand).
I believe knitr considered/implemented something like this with
pre_knit
, though I never figured out how to use it.Beta Was this translation helpful? Give feedback.
All reactions