Repository navigation
fix(transformers): handle split # and -- comments in rose-pine theme - #1317
Conversation
Rose-pine tokenizes `# [!code ++]` into `#` and ` [!code ++]`. The multi-token lookback from shikijs#1118 only accepted a `//` prefix, so notation transformers silently did nothing for yaml, bash, python, sql, lua, etc. Accept any line comment prefix the matcher already supports.
✅ Deploy Preview for shiki-matsu ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for shiki-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1317 +/- ##
==========================================
+ Coverage 89.82% 89.85% +0.03%
==========================================
Files 81 81
Lines 3587 3588 +1
Branches 1028 1026 -2
==========================================
+ Hits 3222 3224 +2
+ Misses 328 327 -1
Partials 37 37 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
a4439c2 to
a485e3a
Compare
|
Heads up on the red check: That is pre-existing on Looks like fallout from a Vitest major, where |
xbetween the brackts.Description
The rose-pine themes tokenize line comments into two tokens:
#and[!code ++]. #1118 added a lookback for this split, but it only accepted a previous token containing//. That means[!code ...]notations did nothing in yaml, bash, python, sql, lua and other languages that use#or--comments. The notation text showed up in the rendered output.This PR changes the lookback check. The previous token can now be any line comment prefix the existing matcher already supports:
//,#,",',;,%or--. The combined text still has to passmatchToken, so nothing else changes.Checked with
rose-pine-dawnagainstdracula, which keeps each comment as one token:foo#[!code ++]…#[!code ++]…--[!code ++]…//[!code ++]Tests added to
notation-diff-rose-pine.test.ts:#comment-only line with[!code highlight:2], checking that the line is removed and the next 2 lines get highlighted.Both fail without the change.
pnpm build && pnpm testpasses (631 tests) andpnpm lintis clean.I used Claude Code to implement this. I reviewed the diff and ran the tests myself.
Linked Issues
fixes #1272
Additional context
Block comments are still split into three tokens in rose-pine (
<!--,[!code ++],-->for html, and/* … */for css), so they are still not handled. The v3 algorithm only looks at the last token on the line, so supporting them would take a bigger change. I left that out to keep this PR small. I can follow up if you'd like.🤖 Generated with Claude Code
https://claude.ai/code/session_01MA8JGs7pCoXFL2W6jEJ8sD