Marked not a function (Markdown Previewer Project)

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

Thanks in advance.

which function you want use?

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

OMG! Thank you very very much!!!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.