1

I am trying to use highlight.js with react but the syntax highlighting is now working. I am trying to store the highlighted syntax inside a variable but the whole content is displayed without highlighting with highlight.js span tags.

import React from "react";
import hljs from "highlight.js";

const test = `const test = require('test')`;
const tt = hljs.highlightAuto(test).value;


function App() {
  return (
    <>
      <pre>
        <code>{tt}</code>
      </pre>
    </>
  );
}

export default App;

1 Answer 1

1

I think react-highlight is built on top of highlight.js

Sign up to request clarification or add additional context in comments.

1 Comment

Looks like it is out-dated now. Not getting updates from 2022

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.