Skip to content

Bug: showLineNumbers not addding corresponding tag to the code element #249

@FarazAhmad541

Description

@FarazAhmad541

Versions
Framework: next@14.2.15
rehype-pretty-code: rehype-pretty-code@0.14.0

next.config.mjs

import nextMDX from '@next/mdx'
import { transformerNotationHighlight } from '@shikijs/transformers'
import rehypePrettyCode from 'rehype-pretty-code'

/** @type {import('rehype-pretty-code').Options} */
const options = {
  theme: 'aurora-x',
  keepBackground: true,
  transformers: [transformerNotationHighlight()],
}

const plugins = []

plugins.push(
  nextMDX({
    extension: /\.(md|mdx)$/,
    options: {
      remarkPlugins: [],
      rehypePlugins: [[rehypePrettyCode, options]],
    },
  })
)

/** @type {import('next').NextConfig} */
const nextConfig = {
  pageExtensions: ['tsx', 'ts', 'jsx', 'js', 'md', 'mdx'],
  images: {
    domains: ['github.com', 'lh3.googleusercontent.com'],
  },
}

export default () => plugins.reduce((_, plugin) => plugin(_), nextConfig)

Sample.mdx

# Hello world
___
This is a test page

Some `backticks` for inline.

```tsx showLineNumbers title="layout.tsx" {5-14} 
import type { Metadata } from 'next'
import localFont from 'next/font/local'
import './globals.css'

const geistSans = localFont({
  src: './fonts/GeistVF.woff',
  variable: '--font-geist-sans',
  weight: '100 900',
})
const geistMono = localFont({
  src: './fonts/GeistMonoVF.woff',
  variable: '--font-geist-mono',
  weight: '100 900',
})

Screenshot of the code Html element

Screenshot from 2024-10-12 14-37-31

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions