Skip to content

fix(transformers): handle YAML comment prefixes correctly for v3#1266

Open
AkaHarshit wants to merge 1 commit intoshikijs:mainfrom
AkaHarshit:fix/transformer-v3-comment-dangling
Open

fix(transformers): handle YAML comment prefixes correctly for v3#1266
AkaHarshit wants to merge 1 commit intoshikijs:mainfrom
AkaHarshit:fix/transformer-v3-comment-dangling

Conversation

@AkaHarshit
Copy link
Copy Markdown

Problem
In the v3 match 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 for v1.

Solution
Introduced v3ClearEndCommentPrefix(comment.info[1]) to notation-transformer.ts to seamlessly erase the matching prefix once the v3 algorithm 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.yaml inside packages/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

  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
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 19, 2026

Deploy Preview for shiki-next ready!

Name Link
🔨 Latest commit a8ca822
🔍 Latest deploy log https://app.netlify.com/projects/shiki-next/deploys/69bc3ff11457170008e61fff
😎 Deploy Preview https://deploy-preview-1266--shiki-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 19, 2026

Deploy Preview for shiki-matsu ready!

Name Link
🔨 Latest commit a8ca822
🔍 Latest deploy log https://app.netlify.com/projects/shiki-matsu/deploys/69bc3ff1462a250008becbbf
😎 Deploy Preview https://deploy-preview-1266--shiki-matsu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.78%. Comparing base (4365957) to head (a8ca822).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Transformers not working properly with YAML comments

1 participant