rajinwonderland / react-code-blocks

React code blocks and code snippet components
https://react-code-blocks.rajinwonderland.vercel.app
MIT License
613 stars 81 forks source link

Bug: line highlighting doesn't work without line numbers #151

Open theDanielJLewis opened 9 months ago

theDanielJLewis commented 9 months ago

When line numbers are not enabled, line highlighting doesn't work. It still fades out everything else, but it does not highlight the desired lines.

This fails:

const code = `<html>
  <body>
  </body>
</html>`;

<CodeBlock
  text={code}
  language="html"
  showLineNumbers={false}
  highlight="2-3"
/>

But this works:

const code = `<html>
  <body>
  </body>
</html>`;

<CodeBlock
  text={code}
  language="html"
  showLineNumbers={true} // The only difference
  highlight="2-3"
/>