Mdx: Headers tags wraps with paragraph

Created on 4 Jun 2019  路  12Comments  路  Source: mdx-js/mdx

Subject of the issue

h1 and H1 tags wraps with unnecessary paragraph tag

Steps to reproduce

you can reproduce this bug in playground

小薪懈屑芯泻 褝泻褉邪薪邪 2019-06-04 胁 10 35 07

Expected behaviour

h1 and H1 tags renders without wrapping p

Actual behaviour

every h1 and H1 tag wraps with paragraph tag

馃悰 typbug

Most helpful comment

This should now be fixed in @mdx-js/[email protected]. Please give it a try and let me know if you encounter any issues.

cc/ @endiliey (a thorough test would be greatly appreciated 馃挓)

All 12 comments

Can confirm this in my project, GatsbyJS / React validates and warns with validateDOMNesting(...): <h2> cannot appear as a descendant of <p>.

It's actually not just unnecessary but not valid HTML.

Also mentioned here on spectrum: https://spectrum.chat/mdx/general/should-literal-h1-be-contained-in-a-p~d6bd0b1d-0a94-4641-b23d-b815e61914e7?authed=true

Also seeing this on my site! In my case it caused some weird visual issues because of the invalid DOM nesting 馃檲

I am curious what version this broke in? I am currently on 1.0.20

Looks like it was a 1.0 regression @chasemccoy. I've opened up #604 with a fix. Thanks for reporting @jeetiss!

@johno thanks man!

I can also reproduce this. Is there any new progress please?

Anything blocking #604 ? :) Would love to help in some way

Anything blocking #604 ? :) Would love to help in some way

Mostly just time : )

Happy to coach someone through picking that PR up, adding some tests and fixing the regex.

Going to pick this back up today and see if I can get a fix in. Will keep you folks posted. 馃

Thank you @johno

Its unfortunate that im on the newbie side for markdown and ast parsing so cant help much. But will keep an eye on the repo and somehow help along if possible

Edit: i can help test if the fix is working later on though 馃槀

This should now be fixed in @mdx-js/[email protected]. Please give it a try and let me know if you encounter any issues.

cc/ @endiliey (a thorough test would be greatly appreciated 馃挓)

Seems to be working great.

Before
before

After
after

Great work :party

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NMinhNguyen picture NMinhNguyen  路  15Comments

ChristianMurphy picture ChristianMurphy  路  13Comments

khrome83 picture khrome83  路  14Comments

lourd picture lourd  路  11Comments

Nkzn picture Nkzn  路  13Comments