highlight.js icon indicating copy to clipboard operation
highlight.js copied to clipboard

R — The first number is not getting the hljs-number class

Open psiaux opened this issue 1 year ago • 1 comments

Describe the issue When the number is next to the <- operator, it doesn't get highlighted. It isn't getting the hljs-number class. HightlightJSRProblem

Which language seems to have the issue? R.

Are you using highlight or highlightAuto? highlight ...

Sample Code to Reproduce

import hljs from 'highlight.js/lib/core'
import r from 'highlight.js/lib/languages/r'
import 'highlight.js/styles/agate.css'

hljs.registerLanguage('r', r)

export default function RCode({ content }: { content: string }) {
  const highlightedCode = hljs
    .highlight(content, { language: 'r' })
    .value
  return
    <pre className={className}>
      <code dangerouslySetInnerHTML={{ __html: highlightedCode }} />
    </pre>
}

The content prop is coming from an MDX file. I'm using Next.js (React) and next-mdx-remote/rsc, using the compileMDX function.

Expected behavior All numbers should be highlighted and have the hljs-number class.

psiaux avatar Jan 27 '24 12:01 psiaux

Please provide actual R source, not just a graphic.

joshgoebel avatar Feb 13 '24 02:02 joshgoebel