Skip to content

Conversation

@cderv
Copy link
Collaborator

@cderv cderv commented Nov 7, 2025

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 in src/resources/rmd/hooks.R was 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) AND nzchar(lang) before adding the dot prefix. Empty strings are now treated the same as NULL (omitted from attributes).

Fixes #13656

…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
@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Nov 7, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Licenses 0 0 0 0 0 issues
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv cderv merged commit 425327e into main Nov 7, 2025
51 checks passed
@cderv cderv deleted the fix-empty-lang-class-13656 branch November 7, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Verbatim R code with empty lang produces invalid {. .cell-code}

3 participants