Skip to content

Fix SCSS analysis failing on same-line prop:value declarations and consecutive semicolons#14688

Merged
cscheid merged 2 commits into
mainfrom
bugfix/issue-14687
Jul 14, 2026
Merged

Fix SCSS analysis failing on same-line prop:value declarations and consecutive semicolons#14688
cscheid merged 2 commits into
mainfrom
bugfix/issue-14687

Conversation

@cscheid

@cscheid cscheid commented Jul 14, 2026

Copy link
Copy Markdown
Member

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-party scss-parser@1.0.6. Two shapes of valid SCSS (Dart Sass compiles both fine) made it throw SCSSParsingError: Expecting punctuation: "}", silently dropping the color export (render still exits 0):

  1. SCSS analysis fails on same-line declarations with no space after colon (.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 in src/core/sass/analyzer/parse.ts was anchored at line start, so same-line declarations escaped it. (Standalone reproduction: https://github.com/gigamonkey/quarto-scss-bug — thanks @gigamonkey.)
  2. SCSS fails to parse #11703 — consecutive semicolons inside a block (an empty statement), e.g. max-height: 100% !important;;, even when the semicolons are separated by whitespace or newlines. Diagnosed by bisecting the personal.scss attached 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

  • New unit test tests/unit/scss-analyzer-parse.test.ts runs 21 valid-but-tricky SCSS shapes through getSassAst plus a cssVarsBlock color-export check (verified to fail without the fixes).
  • New smoke-all regression tests tests/docs/smoke-all/2026/07/14/issue-14687.qmd and issue-11703.qmd, asserting the --quarto-scss-export-* variables survive and no warnings are emitted.
  • Existing SCSS-analysis regression tests (add new scss-parser workaround #12338 corpus, Error adding css vars block SCSSParsingError #14065 unicode tests) still pass.
  • End-to-end: the gigamonkey reproduction renders cleanly (no error, no _quarto_internal_scss_error.scss dump, export block present in the compiled CSS), and SCSS fails to parse #11703's original personal.scss now parses through getSassAst.

🤖 Generated with Claude Code

cscheid and others added 2 commits July 14, 2026 11:44
…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>
@posit-snyk-bot

posit-snyk-bot commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

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

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

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

@cscheid cscheid merged commit c284199 into main Jul 14, 2026
51 checks passed
@cscheid cscheid deleted the bugfix/issue-14687 branch July 14, 2026 17:59
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.

SCSS analysis fails on same-line declarations with no space after colon (.example {width:100px;}) SCSS fails to parse

2 participants