Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self-closing hyphenated shortcoded tag is different when not void #755

Closed
valse opened this issue Aug 29, 2019 · 4 comments · Fixed by #1039
Closed

Self-closing hyphenated shortcoded tag is different when not void #755

valse opened this issue Aug 29, 2019 · 4 comments · Fixed by #1039
Labels
👯 no/duplicate Déjà vu 🐛 type/bug This is a problem

Comments

@valse
Copy link

valse commented Aug 29, 2019

Subject of the issue

Hi, I'm dealing with a strange behavior: if I set a shortcode like this:

const shortcodes = {
 "cc-image": Image,
}

<MDXProvider components={shortcodes}>
   <MDXRenderer>{data.post.body}</MDXRenderer>
</MDXProvider>

and I use it self-closed

# Title

Paragraph

<cc-image />

the rendered html is like:

<h1>Title</h1>
<p>Paragraph</p>
<div class='image'></div>

if I use the same component but not self-closed, the final html include an extra wrapper paragraph for the component itself:

# Title

Paragraph

<cc-image></cc-image>

the rendered html is like:

<h1>Title</h1>
<p>Paragraph</p>
<p>
   <div class='image'></div>
</p>

Expected behaviour

Even if not self-closed the component must not be wrapped in an extra paragraph.

I don't know why but it happens only if the shortcoded tag includes an hyphen :-/

@johno
Copy link
Member

johno commented Aug 29, 2019

Thanks for reporting! This looks like a bug in the remark tokenization.

@johno johno transferred this issue from mdx-js/specification Aug 29, 2019
@johno johno added 🐛 type/bug This is a problem 🙆 yes/confirmed This is confirmed and ready to be worked on labels Aug 29, 2019
@johno
Copy link
Member

johno commented Sep 3, 2019

Also, strangely enough, if there's a newline between the open and close tag it is parsed they way we'd expect:

# Title

Paragraph

<cc-image>
</cc-image>

@wooorm
Copy link
Member

wooorm commented Apr 23, 2020

Weird indeed! This will be fixed in 2.0.0 as we’re rewriting the parser to solve amongst other things, this problem!

@johno
Copy link
Member

johno commented May 21, 2020

I’ve confirmed this is indeed fixed in the v2 prerelease, so going to go ahead and close this.

If you want to give it a shot now: @mdx-js/mdx@next.

@johno johno closed this as completed May 21, 2020
@wooorm wooorm added 👯 no/duplicate Déjà vu and removed 🙆 yes/confirmed This is confirmed and ready to be worked on labels Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👯 no/duplicate Déjà vu 🐛 type/bug This is a problem
Development

Successfully merging a pull request may close this issue.

3 participants