ts-stack/markdown

A way skip initial <P> tag?

lazee opened this issue · 1 comments

lazee commented

First; Thank you for a wonderful Markdown parser!

When using it inside React I think i have to insert generated markup like this

return <div dangerouslySetInnerHTML={{ __html: Marked.parse(markup) }} />

Please advice me if I'm wrong. But then I get this error from React:

Warning: validateDOMNesting(...): <p> cannot appear as a descendant of <div>.

Is there a way to skip the surrounding p-tag generated by the parser ?

Try to use isNoP options:

// isNoP == false
Marked.parse('some text'); // returns '<p>some text</p>'

Marked.setOptions({isNoP: true});

Marked.parse('some text'); // returns 'some text'