Tell us what’s happening:
Describe your issue in detail here.
in which , marked library not work in code pen , what should i do?
Your code so far
import React from 'https://esm.sh/react@18.2.0'
import ReactDOM from 'https://esm.sh/react-dom@18.2.0'
const { useState } = React;
import marked from 'https://cdn.skypack.dev/marked';
import Prism from 'https://cdn.skypack.dev/prismjs';
marked.setOptions({
breaks: true,
highlight: function(code) {
return Prism.highlight(code, Prism.languages.javascript, 'javascript');
},
});
const App = ()=>{
return(
<>
<Editer />
</>
);
}
const Editer=()=>{
const [text, setText] = useState("hello");
const html = marked(text);
return(
<>
<div>
<textarea
id="editor"
value={text}
onChange={(e)=> setText(e.target.value)}>
</textarea>
<div id="preview" dangerouslySetInnerHTML={{ __html: html }}>
</div>
</div>
</>
);
}
ReactDOM.render(<App/>,document.getElementById("root"));
Your browser information:
Challenge: Front End Development Libraries Projects - Build a Markdown Previewer
Link to the challenge: