Skip to content

feat(transformers): add optional message to error level notation#1243

Open
Divyapahuja31 wants to merge 2 commits intoshikijs:mainfrom
Divyapahuja31:feat/notation-message
Open

feat(transformers): add optional message to error level notation#1243
Divyapahuja31 wants to merge 2 commits intoshikijs:mainfrom
Divyapahuja31:feat/notation-message

Conversation

@Divyapahuja31
Copy link
Copy Markdown
Contributor

  • -

Description

This PR enhances the transformerNotationErrorLevel transformer to support custom messages for error, warning, and info levels within code blocks.

Currently, users can only mark a line with a level (e.g., // [!code error]). This update allows users to attach a specific message to the line using the syntax // [!code error:My custom error message]. This message is then rendered as a data-* attribute on the highlighted line, enabling users to display specific error text or tooltips via CSS.

Changes

  • Updated transformerNotationErrorLevel to parse an optional message after the error level (e.g., error:message).
  • The generic range parsing logic was updated to differentiate between numeric ranges (e.g., :3 for 3 lines) and string messages.
  • If a message is provided, it is added as a data-* attribute to the highlighted node (e.g., data-error="My custom error message").
  • Added documentation and examples for the new syntax.
  • Added a new test fixture message.js to verify the output.

Example Usage

Input:

console.error('Error') // [!code error:This is an error message]

@netlify
Copy link
Copy Markdown

netlify bot commented Feb 14, 2026

Deploy Preview for shiki-next ready!

Name Link
🔨 Latest commit 7d81f98
🔍 Latest deploy log https://app.netlify.com/projects/shiki-next/deploys/6990e3b349b2590008497142
😎 Deploy Preview https://deploy-preview-1243--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 Feb 14, 2026

Deploy Preview for shiki-matsu ready!

Name Link
🔨 Latest commit 7d81f98
🔍 Latest deploy log https://app.netlify.com/projects/shiki-matsu/deploys/6990e3b3db85fa00080d0ba5
😎 Deploy Preview https://deploy-preview-1243--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 Feb 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.26%. Comparing base (213f19b) to head (7d81f98).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1243      +/-   ##
==========================================
+ Coverage   95.25%   95.26%   +0.01%     
==========================================
  Files          92       92              
  Lines        8008     8029      +21     
  Branches     1704     1713       +9     
==========================================
+ Hits         7628     7649      +21     
  Misses        374      374              
  Partials        6        6              

☔ 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.

1 participant