Skip to content

#| highlighting alternative - #1088

Open
vezwork wants to merge 1 commit into
mainfrom
feature/hash-pipe-yaml-injection
Open

#| highlighting alternative#1088
vezwork wants to merge 1 commit into
mainfrom
feature/hash-pipe-yaml-injection

Conversation

@vezwork

@vezwork vezwork commented Aug 13, 2026

Copy link
Copy Markdown
Member

Fixes #409

This is an alternative approach to #1084.

Screenshot 2026-08-13 at 5 06 14 PM

This PR is a very simple change: it adds a yaml injection language for #| comments. This means that our syntax highlighting will delegate to the yaml language highlighter inside of #| comments.

The quarto.tmLanguage change is generated from the build-lang.js script.

IMO this is a more "correct" approach, if you will. We lose control over how the yaml looks, but we shouldn't really have that control anyway (let yaml be yaml)?

Pros

  • very simple
  • uses VSCode's yaml highlighting so it'll match frontmatter (which uses the same injection language approach) and yaml files

Cons

  • yaml highlighting is a little visually intense in default themes
  • no background colour
  • possibly has some weird edge cases? I expected multiline yaml stuff to not work well, but it seems to work just fine. I tried using some yaml-feature-test yaml as a hash pipe comment, and it worked well.

Testing note

We could test that the generated tmLanguage delegates #| properly in some examples, in a non-integrated way, by using vscode-textmate and vscode-oniguruma as dependencies in the tests, but that seems a little heavy handed so I didn't do that.

@vezwork vezwork changed the title #| highlighting alternatives #| highlighting alternative Aug 13, 2026
@posit-snyk-bot

posit-snyk-bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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.

@vezwork
vezwork requested a review from juliasilge August 13, 2026 21:09
@vezwork vezwork mentioned this pull request Aug 13, 2026
2 tasks
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.

Add VS Code support to distinguish hash pipe comments from regular comments

2 participants