highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.3k stars 3.52k forks source link

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

Open psiaux opened 5 months ago

psiaux commented 5 months ago

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.

joshgoebel commented 4 months ago

Please provide actual R source, not just a graphic.