Add a Rust grammar to quarto-highlight (rust / rs) - #662
Merged
Conversation
`rust` and `rs` fenced blocks rendered as `<pre class="rust">` with no highlight spans in both `q2 render` and the WASM preview path: the built-in registry carried 13 grammars and Rust was not one of them. Wire tree-sitter-rust 0.24.2 in as a built-in with canonical key `rust` and alias `rs`, using the crate's `HIGHLIGHTS_QUERY` (no vendored copy under resources/highlights/, per the drift-free rule). Injections stay empty, matching the captures-only resolver. All 20 capture names the query emits already resolve through the longest-prefix fallback in the SCSS theme translator and the LSP token legend, so no theme or legend changes. Tests (written first, verified failing on the unregistered class): - all_languages: `rust` / `rs` cases - builtin-snippets.json: rust entry (also feeds the hub-client vitest WASM harness) - smoke-all/highlighting/09-builtin-rust.qmd: end-to-end through `quarto render`, asserting `sourceCode rust`, `sourceCode rs`, `hl-keyword` on `fn` and `hl-function-macro` on `println` Snapshots: 1 added, 0 modified — tests/integration/snapshots/integration__golden__rust.snap. Reviewed span by span: doc comment, `fn`, function name, parameter, `&str` as type.builtin, `String` as type, `format!` as function.macro, string, brackets. All node-exact. Verification: `cargo xtask verify` steps 1–7 green (including the wasm32 link of the grammar's scanner in the hub-client build). Step 8 fails only on the 23 pre-existing Node 26 `localStorage` vitest failures (bd-lh30hlvd), reproduced identically on clean main; `test:wasm` (133) and `test:integration` (119) pass when run directly. End-to-end: `q2 render` and a fresh-WASM `q2 preview` both highlight the probe; evidence in the plan. Plan: claude-notes/plans/2026-09-08-rust-highlight-grammar.md Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UMfCmnsXHFcooUFMaRLxoe
Contributor
✅ 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. |
cscheid
added a commit
that referenced
this pull request
Sep 8, 2026
Resolves the expected overlap with the theme-compile-error work: theme_diagnostic keeps both the Q-14-7 (InvalidScssFile) and Q-14-8 (InvalidBrandFontWeight) arms and the Q-14-6 catch-all replaces this branch's old code-less fallback; SassError::with_location and sass_error_location cover both new variants; the errors sidebar lists Q-14-6, Q-14-7, Q-14-8 in code order. The brand-file bind candidate and main's fallback_location coexist in sass_error_to_parse_error_at. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NE1UEmUUagZwZ5APMZYfra
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.
Summary
rustandrsfenced code blocks rendered as<pre class="rust">with no highlight spans, in bothq2 renderand the WASM preview path: the built-in registry inquarto-highlightcarried 13 grammars and Rust was not among them.This wires
tree-sitter-rust0.24.2 in as a built-in with canonical keyrustand aliasrs, using the crate's ownHIGHLIGHTS_QUERY(no vendored copy, per the drift-free rule;resources/highlights/exists only for Julia, whose crate lacks the constant). Injections stay empty, matching the captures-only resolver. All 20 capture names the query emits already resolve through the longest-prefix fallback in the SCSS theme translator and the LSP token legend, so no theme or legend changes.Strand: bd-202u5bld (parent bd-n7x2). Plan with the full scouting table and evidence:
claude-notes/plans/2026-09-08-rust-highlight-grammar.md.Tests (written first, verified failing on the unregistered class)
all_languages.rs:rust/rscasesbuiltin-snippets.json: Rust entry (also feeds the hub-client vitest WASM harness)smoke-all/highlighting/09-builtin-rust.qmd: end-to-end throughquarto render, assertingsourceCode rust,sourceCode rs,hl-keywordonfn,hl-function-macroonprintlnSnapshots: 1 added, 0 modified —
integration__golden__rust.snap, reviewed span by span (doc comment,fn, function name, parameter,&strastype.builtin,Stringastype,format!asfunction.macro, string, brackets; all node-exact).Verification
cargo xtask verifysteps 1–7 green, including the hub-client WASM build (the grammar's C scanner uses the sameisw*calls as bash and links on wasm32 viawasm-c-shim).test:ci) fails only on the 23 pre-existing Node 26localStoragefailures tracked in bd-lh30hlvd, reproduced identically on cleanmain.test:wasm(133) andtest:integration(119) pass when run directly.q2 renderon a probe emitssourceCode rust/sourceCode rsblocks withhl-keyword,hl-type-builtin,hl-function-macrospans;q2 previewwith freshly rebuilt WASM highlights the same probe (inspected in headless Chromium).Upstream-query behaviours inherited from tree-sitter-rust, noted in the plan: integer literals are captured as
constant.builtin;let-bound names and->carry no capture.🤖 Generated with Claude Code
https://claude.ai/code/session_01UMfCmnsXHFcooUFMaRLxoe