Skip to content

Conversation

@dahiya001rohit
Copy link

@dahiya001rohit dahiya001rohit commented Dec 3, 2025

  • Implement transformerRenderLineNumber to inject line numbers as HTML elements.
  • Support customization options: classLineNumber and startNumber.
  • Export the new transformer in the main index file.
  • Add unit tests to verify functionality.

#1201

Copilot AI review requested due to automatic review settings December 3, 2025 13:52
@netlify
Copy link

netlify bot commented Dec 3, 2025

Deploy Preview for shiki-matsu ready!

Name Link
🔨 Latest commit 769a09c
🔍 Latest deploy log https://app.netlify.com/projects/shiki-matsu/deploys/6930596173953a00083c3c7d
😎 Deploy Preview https://deploy-preview-1202--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.

@netlify
Copy link

netlify bot commented Dec 3, 2025

Deploy Preview for shiki-next ready!

Name Link
🔨 Latest commit 769a09c
🔍 Latest deploy log https://app.netlify.com/projects/shiki-next/deploys/6930596109bd0200084e6db1
😎 Deploy Preview https://deploy-preview-1202--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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new transformer transformerRenderLineNumber that injects line numbers as HTML elements into syntax-highlighted code blocks. The transformer allows developers to visually display line numbers alongside their code, with customization options for the CSS class name and starting line number.

  • Implements transformerRenderLineNumber with configurable classLineNumber and startNumber options
  • Adds comprehensive unit tests covering basic functionality, custom classes, and custom start numbers
  • Exports the new transformer in the package index

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/transformers/src/transformers/render-line-number.ts New transformer implementation that prepends line number spans to each code line
packages/transformers/src/index.ts Exports the new transformer in alphabetical order with other transformers
packages/transformers/test/render-line-number.test.ts Unit tests covering basic usage, custom class names, and custom start numbers
packages/transformers/test/snapshots/render-line-number.test.ts.snap Snapshot tests validating the HTML output for all test cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

type: 'element',
tagName: 'span',
properties: {
className: [classLineNumber],
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with other transformers in this codebase (e.g., render-indent-guides.ts, meta-highlight-word.ts), use class instead of className in HAST element properties. Both work, but class is the convention used throughout this codebase.

class: classLineNumber,
Suggested change
className: [classLineNumber],
class: [classLineNumber],

Copilot uses AI. Check for mistakes.
{
type: 'text',
value: `${number}`,
} as Text,
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The as Text type assertion is unnecessary. The object literal already matches the Text type. Consider removing it for cleaner code:

children: [
  {
    type: 'text',
    value: `${number}`,
  },
],
Suggested change
} as Text,
},

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Dec 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.22%. Comparing base (61c87e8) to head (769a09c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1202      +/-   ##
==========================================
+ Coverage   95.20%   95.22%   +0.01%     
==========================================
  Files          92       93       +1     
  Lines        7922     7954      +32     
  Branches     1689     1694       +5     
==========================================
+ Hits         7542     7574      +32     
  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