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

[BUG] Implicit self closing HTML tags (e.g. <br>) are unsupported by the editor #472

Open
2 tasks done
mlequime opened this issue May 28, 2024 · 1 comment
Open
2 tasks done
Labels
bug Something isn't working

Comments

@mlequime
Copy link
Contributor

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • I have read the documentation and cannot find an answer.

Describe the bug
Implicit self-closing HTML tags like <img> and <br> fail to load in the MDX editor as they 'have an unmatched closing tag'.

Reproduction
Repro sandbox

To Reproduce
Steps to reproduce the behavior:

  1. First editor fails to load

Expected behavior

renders as a linebreak as supported in most flavours of markdown

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: any

Additional context
HTML tags appear to be parsed with the JSX parser, which is expecting a self-closing tag marker or an end tag (to be valid JSX syntax)

@mlequime mlequime added the bug Something isn't working label May 28, 2024
@petyosi
Copy link
Contributor

petyosi commented May 28, 2024

If you turn on suppressHtmlProcessing (thus, disabling the JSX parser), you're going to get those tags as HTML strings parse time; From there, you can write a visitor that handles them. However, this can get really messy for img tags due to attribute order, casing, quotes etc.

I do understand that this is good to be supported, but writing an HTML parser is very complicated. I would honestly instead consider some pre-processing and sanitization of the markdown instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants