Neno-N
March 16, 2022, 8:40am
1
Hi, I am attempting the Markdown Previewer project and I installed ‘marked’ and ‘react’ in the JS settings on codepen. However, when I use the :
const markdown = marked(text);
… my whole code stops working and in the console it says “marked is not a function”.
I also tried installing marked by the “Add Packages” part of the JS settings and that did not work either.
This is my first time using marked and EVEN react on code pen so any help would be greatly appreciated.
Here’s my code https://codepen.io/neno-n/pen/eYyNyeO?editors=0010
Thanks in advance.
Neno-N:
marked
which function you want use?
https://marked.js.org/using_pro
Neno-N
March 16, 2022, 1:51pm
3
I want to use the function that converts the markdown into html. I’m not really sure which function that is and when I try to look for tutorials or solutions, they all say I must use:
const markdown = marked(text);
<div dangerouslySetInnerHTML = {{__html : markdown}} />
I’ve spent all morning trying to find a solution. I also read the information on the link you sent but I still don’t understand what is wrong.
Use the .parse()
method and remember to actually use the markdown
variable in the dangerouslySetInnerHTML
(you are not in the Codepen).
Also, just an FYI the markdown syntax for a heading is # heading
, not #heading
(space after #
) .
1 Like
Neno-N
March 16, 2022, 2:23pm
5
OMG! Thank you very very much!!!
system
Closed
September 15, 2022, 2:24am
6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.