fix(transformers): handle YAML comment prefixes correctly for v3#1266
Open
AkaHarshit wants to merge 1 commit intoshikijs:mainfrom
Open
fix(transformers): handle YAML comment prefixes correctly for v3#1266AkaHarshit wants to merge 1 commit intoshikijs:mainfrom
AkaHarshit wants to merge 1 commit intoshikijs:mainfrom
Conversation
Improve `notation-transformer` to utilize `v3ClearEndCommentPrefix` so that dangling comment prefixes (e.g., `# ` in YAML) are completely removed when the comment notation is matched and stripped. Fixes: shikijs#1007
✅ Deploy Preview for shiki-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for shiki-matsu 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 #1266 +/- ##
==========================================
+ Coverage 89.66% 89.78% +0.11%
==========================================
Files 79 79
Lines 3512 3513 +1
Branches 1007 1008 +1
==========================================
+ Hits 3149 3154 +5
+ Misses 327 324 -3
+ Partials 36 35 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Problem
In the
v3match algorithm for@shikijs/transformers, using transformer notations such as[!code ++]within YAML files left behind a dangling comment character#. This happened because the core parser appropriately matched the line, but neglected to clear the comment prefix explicitly as it did forv1.Solution
Introduced
v3ClearEndCommentPrefix(comment.info[1])tonotation-transformer.tsto seamlessly erase the matching prefix once thev3algorithm matches a code notation like[!code focus]or[!code ++]. This allows Shiki to then properly identify the resulting empty string and remove the entire dangling line comment.Testing
Created a new diff test fixture
1007.yamlinsidepackages/transformers/test/fixtures/diff/mapping to the user's report, and confirmed that snapshots update correctly to strip out#without regressions across other files.Linked Issue
Fixes: #1007