I have everything working fine apart from inline code block highlighting using Prism.js.
I have it working for anything within <pre><code> tags when I use 3 x escaped back ticks.  However anything within 1 x escaped back ticks which shows as just <code> tags on inspection is not being detected/highlighted.
I guess my main concern is I feel I’m not completely understanding the documentation for Marked.js highlighting section or what the following does:
const renderer = new marked.Renderer();
I have resorted to copying the highlight function inside marked.setOptions () from the example code project, but mine works with or without the line above. I also read an article where someone used the Prism API and Prism.highlightAll() inside useEffect (commented out in my code) but that wouldn’t work at all.
I have put code below for just my Previewer.js component (I’m using VS code and trying to upload all projects to github pages for practise).
Can anyone point me to any articles or anything that might help me understanding the docs for Prism.js and Marked.js as I think I’m quite poor at understanding docs. I don’t like copying things without understanding them.
To summarise I don’t completely understand the following:
1.
    highlight: function (code) {
        return Prism.highlight(code, Prism.languages.javascript, 'javascript');
      } 
How did the example project get to that from reading this in the marked.js docs example as the above is so much lighter:
“Using Advanced - Marked Documentation”
    highlight: function(code, lang, callback) {
    require('pygmentize-bundled') ({ lang: lang, format: 'html' }, code, function (err, result) {
      callback(err, result.toString());
    });
  }
- Why are people using the following when mine works without.
const renderer = new marked.Renderer(); 
and then passing in {renderer: renderer} as additional argument to marked() in the dangerouslySetInner HTML object?
- Why is Prism therefore  only detecting (and highlighting) my 
<pre> <code>tags and not just the<code>tags 
My code below. I’ve searched around for days, but can’t seem to get my head round it and I find the documentation for both libraries very cryptic, which I’m sure says more about me than the docs!
import React from 'react';
import { useEffect } from 'react';
import './TextAreas.css';
import Prism from 'prismjs';
import 'prismjs/themes/prism.css';
const marked = require("marked");
marked.setOptions({
    breaks: true,
    highlight: function (code) {
        return Prism.highlight(code, Prism.languages.javascript, 'javascript');
      }
  });
const renderer = new marked.Renderer();
export default function Previewer(props) {
//const renderer = new marked.Renderer();
   /* useEffect(() => {
        Prism.highlightAll();
      }) */
    return (
        <div className="text-container">
            <div
            //ref={outputTextArea}
            className="preview-area" 
            dangerouslySetInnerHTML={{__html: marked(props.text, {renderer: renderer})}}
            id="preview" 
            style={{paddingTop: "0px", paddingBottom: "0px", paddingLeft: "1em"}} 
            >
            </div>
        </div>
    )
}