Skip to content

Trying to understand how rehypeReact inserts custom React nodes #128

Discussion options

You must be logged in to vote

Welcome @ChristopherPAndrews! 👋
Yes, the behavior is expected, it's how HTML works.
An example with <div> which illustrates what the expected behavior is:

<div/><span></span><span></span>

This will be parsed into:

  • html
    • head
    • body
      • div
        • span
        • span

The trailing U+002F (/) in a start tag name can be used only in foreign content to specify self-closing tags. (Self-closing tags don't exist in HTML.) It is also allowed for void elements, but doesn't have any effect in this case.

https://html.spec.whatwg.org/multipage/parsing.html#parse-error-non-void-html-element-start-tag-with-trailing-solidus

<test/> is not self closing (these exist in XML, not in HTML) nor is it a void element in HTML.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@ChristopherPAndrews
Comment options

@ChristianMurphy
Comment options

@ChristopherPAndrews
Comment options

@ChristianMurphy
Comment options

@ChristopherPAndrews
Comment options

Answer selected by ChristianMurphy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants