Skip to content

MDX with "html" tag in JSX fails #6943

@Tigge

Description

@Tigge

Prettier 1.19.1
Playground link

--parser mdx

Input:

import     {     Foo,  Bar } from     './Fixture'

# Hello,    world!

<Foo bg='red'>
   <div style={{   display:   'block'}   }>
      <Bar    >hi    </Bar>
       </div>
</Foo>

Output:

SyntaxError: Unexpected closing tag "div". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (4:8)
  2 | 
  3 | # Hello,    world!
> 4 | 
    | ^
  5 | <Foo bg='red'>
  6 |    <div style={{   display:   'block'}   }>
  7 |       <Bar    >hi    </Bar>

Expected behavior:

In prettier 1.18.2 this worked fine, but now it seems that the div tag is parsed as html (judging from the stack trace) and fails. The example above also renders correctly in the MDX playground at https://mdxjs.com/playground. Result JSX is:

    <h1>{`Hello,    world!`}</h1>
    <Foo bg='red' mdxType="Foo">
   <div style={{
        display: 'block'
      }}>
      <Bar mdxType="Bar">hi    </Bar>
       </div>
    </Foo>

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:mdxIssues affecting the MDX extension to Markdown (not general Markdown issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions