hashicorp / next-mdx-remote

Load MDX content from anywhere
Mozilla Public License 2.0
2.67k stars 140 forks source link

Cannot parse HTML <br> tag #284

Closed Eliot00 closed 2 years ago

Eliot00 commented 2 years ago

I use tui.editor to write markdown blog, it will add some soft line break, next-mdx-remote can't serialize it, even <br> is a legal HTML tag without slash.

Error: [next-mdx-remote] error compiling MDX:
Expected a closing tag for `<br>`
    "next": "^12.1.0",
    "next-mdx-remote": "^4.0.3",
noahlst commented 2 years ago

<br> and other HTML components that don't need a closing tag aren't valid in React. So try <br />

Eliot00 commented 2 years ago

<br> and other HTML components that don't need a closing tag aren't valid in React. So try <br />

I need to build blog pages which write by users, and their editor will auto insert <br> into markdown text, is there some plugins can convert it to valid MDX format?

patradanai commented 2 years ago

i have same issue wuth tui editor

BRKalow commented 2 years ago

This is a limitation of MDX: https://mdxjs.com/docs/

You might consider trying to force the content to be parsed as vanilla markdown, instead of mdx.

serialize(content, { mdxOptions: format: 'md' })

Note that you won't be able to use MDX components with this approach.

talatkuyuk commented 1 year ago

I suffer from the same issue. I think there should be a solution.