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

Errors on presumed MDX expression with curly braces #318

Open
dave-db opened this issue Jan 19, 2024 · 2 comments
Open

Errors on presumed MDX expression with curly braces #318

dave-db opened this issue Jan 19, 2024 · 2 comments

Comments

@dave-db
Copy link

dave-db commented Jan 19, 2024

A string in {curly braces} within the body of a document is being parsed as an MDX expression, then throwing as there's no node handler for it. The same text content is processed ok by MDX evaluate/parse itself, so it looks like it relates to the conversion pipeline between markdown and Lexical.

Example content

Find your video at:

https://player.evideo.com/video?video-id={your-video-id}

> Replace `your-video-id` with your video id

The part in {curly braces} blew up the editor, but not the MDX processor (mdx-js evaluateSync), which rendered it fine unescaped. The editor error was:

Error: Cannot handle unknown node `mdxTextExpression`
    at Object.unknown (webpack-internal:///(:3000/admin/app-pages-browser)/./node_modules/@mdxeditor/editor/node_modules/mdast-util-to-markdown/lib/index.js:120:11)
    at Object.one [as handle] (webpack-internal:///(:3000/admin/app-pages-browser)/./node_modules/zwitch/index.js:112:17)
    at toMarkdown (webpack-internal:///(:3000/admin/app-pages-browser)/./node_modules/@mdxeditor/editor/node_modules/mdast-util-to-markdown/lib/index.js:85:24)
    at visit (webpack-internal:///(:3000/admin/app-pages-browser)/./node_modules/@mdxeditor/editor/dist/importMarkdownToLexical.js:78:156)
    at eval (webpack-internal:///(:3000/admin/app-pages-browser)/./node_modules/@mdxeditor/editor/dist/importMarkdownToLexical.js:68:45)

Originally posted by @dave-db in #312 (reply in thread)

@petyosi
Copy link
Contributor

petyosi commented Jan 19, 2024

Thank you, I will test that. To ensure I'm not missing something, in that case, you would rather not have any special processing of the {your-video-id} token, right?

@dave-db
Copy link
Author

dave-db commented Jan 19, 2024

Yup, absolutely - it should be just string content in the link (in this case). Looking at the docs for mdast-util-mdx-expression, I think the whitespace around braces should be treated as significant, although I'm not clear on exactly what the spec is. mdx-js itself doesn't try to parse it (at least in my pipeline), so maybe I don't have that plugin enabled for rendering pages?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants