shikijs / shiki

A beautiful yet powerful syntax highlighter

Home Page:http://shiki.style/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Row of `language-*` on a single `code` element

piscopancer opened this issue · comments

Validations

Describe the bug

image

shiki is used on the server as a rehype plugin
my config

export const rehypeShikiOptions = {
  themes: { light: theme },
  langs,
  addLanguageClass: true,
} satisfies RehypeShikiOptions

then it is used in MDX remote server component

import { rehypeShikiOptions } from '@/app/shiki'
import shiki from '@shikijs/rehype'
import { MDXRemote } from 'next-mdx-remote/rsc'
import remarkGfm from 'remark-gfm'
import remarkUnwrapImages from 'remark-unwrap-images'
import { components } from '.'

export function ServerMDX(props: { text: string }) {
  return (
    <MDXRemote
      source={props.text}
      options={{
        mdxOptions: {
          remarkPlugins: [remarkGfm, remarkUnwrapImages],
          rehypePlugins: [[shiki, rehypeShikiOptions]],
        },
      }}
      components={components}
    />
  )
}

I did not do any sort of modifications, however when there are more than 1 code blocks in my md/mdx, shiki decides to apply multiple languages to a single code element

Reproduction

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests

We temporarily closed this due to the lack of enough information. We could not identify whether it was a bug or a userland misconfiguration with the given info.
Please provide a minimal reproduction to reopen the issue.
Thanks.

Why reproduction is required