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

Compile into a valid page even on invalid syntax #2539

Closed
4 tasks done
Iceburgino opened this issue Sep 22, 2024 · 3 comments
Closed
4 tasks done

Compile into a valid page even on invalid syntax #2539

Iceburgino opened this issue Sep 22, 2024 · 3 comments
Labels
🙅 no/wontfix This is not (enough of) an issue for this project

Comments

@Iceburgino
Copy link

Initial checklist

Problem

MDX is an ideal format for writing documents. It's versatile and simple. And yet it can't be used that way because of parsing errors of JSX. The user that is just writing a document (like docx), and not a webpage, is not accustomed an error just discarding the entire page.

Solution

Something akin to what tree-sitter does - localizing erroneous part and parsing it as text.

Alternatives

Nothing comes to mind that's better than proposed. Maybe rendering the older version of the page.

@ChristianMurphy
Copy link
Member

Hey @Iceburgino! 👋
There will not be a loose mode in core MDX.
That isn't how JSX/XML work, the document needs to be fully valid.

If you want an authoring experience that previews faster, take a look at mdx-js/mdx-analyzer#267

And if you need a more forgiving parser.
Use markdown, there is no such thing as an invalid document in plain markdown.

@ChristianMurphy ChristianMurphy closed this as not planned Won't fix, can't repro, duplicate, stale Sep 22, 2024
@ChristianMurphy ChristianMurphy added the 🙅 no/wontfix This is not (enough of) an issue for this project label Sep 22, 2024
@Iceburgino
Copy link
Author

@ChristianMurphy Unfortunately, using markdown is not viable for us, as it's too simple to satisfy customer needs. The authoring experience needs to be something like in obsidian, where you can type in the part, and it will not crash the app but just won't render properly. I presume the link you provided tackles the problem of syntax highlighting, but not previewing partial results?

@remcohaszing
Copy link
Member

I recommend that you keep around the last version that could render. Then if the user introduces a syntax error, you render the previous version instead.

Additionally I recommend to integrate Volar with MDX language service in your text editor, so you can display errors in the editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 no/wontfix This is not (enough of) an issue for this project
Development

No branches or pull requests

3 participants