Conversation
When filename is set via the #| filename: Quarto chunk option, Quarto stores the value in its internal custom node registry and wraps the CodeBlock in a DecoratedCodeBlock Div, leaving the inner CodeBlock without a filename attribute. The pre-quarto filter saw no explicit filename and fell back to auto-filename, causing two problems: - HTML: auto-filename set the language name as filename, which the injected JS then used to create a second .code-with-filename wrapper alongside the one Quarto already created from #| filename:. - Typst: the code-window wrapper used the auto-generated language name instead of the user-specified filename. Fix by reading the filename from _quarto.ast.custom_node_data via the __quarto_custom_id attribute on the DecoratedCodeBlock Div. For Typst the transfer happens in the existing DecoratedCodeBlock branch of process_typst_blocks. For HTML a new Pandoc filter branch runs fix_html_decorated_filenames before the CodeBlock filter, so process_html sees the explicit filename and skips auto-filename.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
filenameis set via the#| filename:Quarto chunk option, Quarto stores the value in its internal custom node registry and wraps the CodeBlock in aDecoratedCodeBlockDiv, leaving the inner CodeBlock without afilenameattribute. The pre-quarto filter saw no explicit filename and fell back to auto-filename.In HTML this caused a double
.code-with-filenamewrapper: one created by Quarto from#| filename:and a second created by the extension's injected JavaScript for the auto-filename. In Typst thecode-windowwrapper showed the auto-generated language name instead of the user-specified filename.The fix reads the filename from
_quarto.ast.custom_node_datavia the__quarto_custom_idattribute present on everyDecoratedCodeBlockDiv. For Typst the transfer happens in the existingDecoratedCodeBlockbranch ofprocess_typst_blocks. For HTML a newPandocfilter branch runsfix_html_decorated_filenamesbefore theCodeBlockfilter, soprocess_htmlsees the explicit filename and skips auto-filename.The
{.r filename="..."}Pandoc attribute syntax is unaffected.