Skip to content

#| highlighting alternative - #1088

Merged
vezwork merged 1 commit into
mainfrom
feature/hash-pipe-yaml-injection
Aug 14, 2026
Merged

#| highlighting alternative#1088
vezwork merged 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
@vezwork

vezwork commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

@mine-cetinkaya-rundel what do you think of this approach #1088 to #| highlighting v.s. #1084 (comment)? The highlights (pun intended) are that this approach is simpler and uses built-in yaml highlighting so it'll be consistent across the IDE, but gives us less control so we can't i.e. have a background behind the #| comment lines.

@vezwork
vezwork merged commit a22948c into main Aug 14, 2026
6 of 7 checks passed
@vezwork

vezwork commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

whoops, accidentally merged this branch into main somehow. Gonna undo that.

@mine-cetinkaya-rundel

Copy link
Copy Markdown
Contributor

@vezwork Even though there's no background color, there's still a line separating the yaml code cell options and the code, is that correct? If so, that's pretty good still for the visiual differentiation between the two pieces of the code cell.

@vezwork

vezwork commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

@mine-cetinkaya-rundel there's no line. Actually, let me look into combining these two approaches. Maybe we can use built-in yaml highlighting and also add a background.

@vezwork

vezwork commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

This PR was accidentally merged to main and then reverted. The PR continues in #1092. Sorry for confusion

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

3 participants