Fix R code cells with empty lang option producing invalid class attributes#13659
Merged
Conversation
…butes
When R code cells use `lang: ""`, the empty string was being converted to
an invalid class attribute `{. .cell-code}` (space after period with no
language). This appeared as literal text in output instead of being parsed
as a valid code block attribute.
Root cause: `block_attr()` function in hooks.R was adding dot prefix to
empty strings. Now checks both NULL and empty string before adding prefix.
Fixes #13656
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
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 rendering R code cells with
lang: "", Quarto would produce invalid class attributes that appeared as literal text in output instead of being parsed correctly.Root Cause
The
block_attr()function insrc/resources/rmd/hooks.Rwas adding a dot prefix to empty string language values, creating invalid attributes like{. .cell-code}(space after period with no language).Empty strings were treated differently from NULL, even though both represent "no language".
Fix
Modified
block_attr()to check both!is.null(lang)ANDnzchar(lang)before adding the dot prefix. Empty strings are now treated the same as NULL (omitted from attributes).Fixes #13656