-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding label to callout in filter fails to generate correct xref #11362
Comments
Yes, it looks like the callout blocks have been comprehensively pre-processed before they reach the filters. For example, even if I add a class to a callout note in source, it is stripped before it reaches the filter. That is: ::: {.callout-note .my-class}
::: becomes: ::::: {__quarto_custom="true" __quarto_custom_type="Callout" __quarto_custom_context="Block" __quarto_custom_id="1"}
::: {__quarto_custom_scaffold="true"}
:::
::: {__quarto_custom_scaffold="true"}
:::
::::: by the time the filter gets it. Is there a way to filter before Quarto does this kind of preprocessing? |
Yes, there is a way to change the order: (It's a bit hidden for now, but this documentation issue is tracked by other issue) |
Aha - yes - thanks - specifying But I noticed, post-processing, Quarto discards any extra classes or attributes to the callout div. For this input: ::: {.callout-note .nb-end foo="bar"}
## Another callout
::: I get the Markdown equivalent of this output when running in a ::::: {__quarto_custom="true" __quarto_custom_type="Callout" __quarto_custom_context="Block" __quarto_custom_id="2"}
::: {__quarto_custom_scaffold="true"}
Another callout
:::
::: {__quarto_custom_scaffold="true"}
:::
::::: This is an issue because I want to mark some callout blocks with extra classes, so I can use them in a Just FYI, although the documentation above says that any extension other than filters:
- at: pre-ast
path: add_section_target.py
type: json
- at: pre-ast
path: add_callout_target.py
type: json Without the explicit
|
Quarto strips classes and attributes from callouts, so put these into custom divs instead. See: quarto-dev/quarto-cli#11362
I have an in-progress PR open that will address this by making it possible to handle custom nodes in JSON filters #11241 but the changes were too big to do in 1.6. |
Bug description
When writing a filter for callouts, but not sections - Quarto does not correctly detect xref label that I have added in the filter.
See: https://github.com/matthew-brett/filter-notes-no-xrefs
In this repository, I am trying, through filtering, to generate the equivalent output as I would get from the following
direct.qmd
input (also in the repository:I am manipulating the following input
.qmd
document using a couple of trivial (in my case) Panflute Pandoc JSON filters:My filters replace the AST for
## My header mark-for-section-target
with## My filtered header {#sec-my-filtered-section}
- and this works correctly to generate the section xref target. But my filters also replace the AST for the callout note with:::: {#nte-my-filtered-note .callout-note} ## My filtered heading :::
and this fails - both in generating correct HTML output for the callout note, and in generating the xref for the callout note. See below for the steps to reproduce, and more detail.
Steps to reproduce
See: https://github.com/matthew-brett/filter-notes-no-xrefs.
I believe my filters are correct, and I have explicitly specified these filters should run before
quarto
, although I believe this is the default. The filters areadd_section_target.py
andadd_callout_target.py
in the repository.To reproduce, clone the repository.
quarto render direct.qmd
generates the expected HTML output without warnings.quarto render filtered.qmd
gives the warningWARNING (/Users/mb312/dev_trees/quarto-cli/src/resources/filters/./crossref/refs.lua:127) Unable to resolve crossref @nte-my-filtered-note
showing that the callout note filter output was not interpreted correctly, confirmed by the output HTML.quarto render direct.qmd --to markdown
generates this (as expected):However,
quarto render filtered.qmd --to markdown
generates this:Expected behavior
See above. The filtered output should be equivalent to the following direct output, and adding the xref to the Markdown, via the filter, should generate the xref target, as for the direct version.
Actual behavior
See above.
Your environment
Quarto check output
Quarto check output
The text was updated successfully, but these errors were encountered: