Marked.js - Trouble rendering

Here’s my code so far:

Links, code, images and bolded text render but not h1, h2, list items and blockquotes. I couldn’t find anything online, so I would appreciate it if someone could point out what is wrong with my code…

EDIT: I redid this with React and now in the preview I get HTML tags that are not parsed. What can I do to make this work?

Use this:

<div id="preview" dangerouslySetInnerHTML={{ __html:marked(this.state.input) }}></div>

Also remove the marked wrapper around the input initial text and pay attention to the markdown syntaxis.

I’m not exacty sure what in particular you’re referring to when you say:

The first line, for example. You used “#Text” and it should be “# Text”.

1 Like

Wow! I didn’t think a spce would make the difference. One last thing: could you point out what’s wrong with my blockquote?

Nothing wrong, you just need to give it some styles. If you inspect the output code with the developer tools you’ll see that the blockquote tag is already present inside the #preview div.

You’re right. Turns out that I had forgotten to add a code block. Thank a lot for your help!

1 Like