quarto-dev / quarto-dev/quarto
Typst grammar bug leaves string scope unclosed, breaking highlighting in code blocks and `.typ` files
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 645
- Forks
- 62
- Avg merge
- 17h 42m
- Merged PRs (30d)
- 13
Description
Bug description
Quarto's Typst TextMate grammar has a parsing bug: it fails to recognize the closing quote of a string if it contains a # inside a #context block.
Impact on standalone .typ files:
Because Quarto injects this grammar globally into source.typst, this exact same bug completely breaks the syntax highlighting for standalone .typ files as well, overriding dedicated extensions like Tinymist.
Steps to reproduce
- Create a
test.qmdfile. - Paste the following code:
```typst
#context {
let c = rgb("#8C6A48")
}
= Heading
Text
```
(Note: The exact same issue can be reproduced in a standalone test.typ file with the Quarto extension enabled.)
Actual behavior
Everything after "#8C6A48" (including = Heading and Text) is incorrectly highlighted as a string because the scope never closes.
Inside a .qmd file, the markdown code fence barely contains the leak. However, in a standalone .typ file (which has no markdown fences), this single bug breaks the syntax highlighting for the entire rest of the file down to EOF.
Expected behavior
- The Typst grammar should correctly recognize the closing quote of strings containing
#and close the string scope. - Quarto's Typst grammar injection should ideally be restricted to
.qmd/.mdfiles, or there should be an opt-out setting for standalone.typfiles to prevent global conflicts with native Typst tooling.
Your environment
- IDE: VSCode v1.130.0
- Quarto Extension: v1.135.0
- Tinymist Extension: v0.15.2
- OS: Windows 11
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Quarto's Typst TextMate grammar and reproduce the leak in the supplied test.qmd example and a standalone test.typ file with the Quarto extension enabled. Determine how strings containing # inside #context are scoped and how the grammar is injected into source.typst. Done means the closing quote ends the string scope and standalone Typst highlighting no longer conflicts with native tooling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- vscode
- Domain
- devtools, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100