Fix SCSS analysis failing on same-line prop:value declarations and consecutive semicolons#14688
Merged
Conversation
…er colon (#14687) scss-parser cannot tokenize `prop:value` (no space after the colon) unless the value is a bare identifier. The existing workaround in analyzer/parse.ts only rescued declarations at line start, so rules like `.example {width:100px;}` reached the raw parser, cssVarsBlock threw SCSSParsingError, and the --quarto-scss-export-* block was silently dropped. Add a sibling rewrite covering declarations that follow `{` or `;` on the same line. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
scss-parser throws on consecutive semicolons inside a block (an empty
statement, valid CSS/SCSS), even when separated by whitespace or
newlines, e.g. `a { b: 1;; }`. Collapse each run of semicolons into
one before parsing, alongside the other analyzer text workarounds.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Closes #14687, closes #11703.
Problem
cssVarsBlock(the SCSS static analysis that exports theme colors as--quarto-scss-export-*CSS variables) parses the assembled SCSS bundle with the brittle third-partyscss-parser@1.0.6. Two shapes of valid SCSS (Dart Sass compiles both fine) made it throwSCSSParsingError: Expecting punctuation: "}", silently dropping the color export (render still exits 0):.example {width:100px;}) #14687 — a declaration on the same line as the opening brace, with no space after the colon and a non-identifier value, e.g..example {width:100px;}. The existing colon-spacing workaround insrc/core/sass/analyzer/parse.tswas anchored at line start, so same-line declarations escaped it. (Standalone reproduction: https://github.com/gigamonkey/quarto-scss-bug — thanks @gigamonkey.)max-height: 100% !important;;, even when the semicolons are separated by whitespace or newlines. Diagnosed by bisecting thepersonal.scssattached to that issue; with the;;collapsed, the whole file parses.Fix
Two more targeted text rewrites in
src/core/sass/analyzer/parse.ts, alongside the six existing workarounds of the same kind (these rewrites only affect the analysis copy of the SCSS, never what Dart Sass compiles):/([{;]\s*[A-Za-z0-9-]+):([^ \n])/g → "$1: $2"— same-line sibling of the existing line-start colon fixup./;[\s;]*;/g → ";"— collapse each run of semicolons into one.Tests
tests/unit/scss-analyzer-parse.test.tsruns 21 valid-but-tricky SCSS shapes throughgetSassAstplus acssVarsBlockcolor-export check (verified to fail without the fixes).tests/docs/smoke-all/2026/07/14/issue-14687.qmdandissue-11703.qmd, asserting the--quarto-scss-export-*variables survive and no warnings are emitted._quarto_internal_scss_error.scssdump, export block present in the compiled CSS), and SCSS fails to parse #11703's originalpersonal.scssnow parses throughgetSassAst.🤖 Generated with Claude Code