Skip to content

Commit 9750ccd

Browse files
committed
docs: add notes about mdx comment syntax change
1 parent a37d400 commit 9750ccd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

doc-site/pages/upgrade-from-v3-to-v4$.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ Update `package.json`:
6666
}
6767
```
6868

69+
## MDX Comment Syntax Change
70+
71+
mdx v2 drops support for HTML comment syntax `<!-- html comment -->` (actually it drops all HTML syntax), and [the document](https://mdxjs.com/docs/what-is-mdx/#markdown) recommends using jsx comment syntax instead:
72+
> HTML syntax doesn’t work in MDX as it’s replaced by JSX. Instead of HTML comments, you can use JavaScript comments in braces: `{/* comment! */}`.
73+
74+
The author explain the reason behind this at [this rfc](https://github.com/mdx-js/mdx/issues/1042#issuecomment-622281752). The author hopes that the mdx syntax is only composed of markdown syntax + JSX syntax. The introduction of HTML syntax is not necessary and it would increase the mental burden.
75+
76+
> Although many markdown parsers support HTML syntax, it is technically not the syntax of markdown itself. Those markdown parsers support it because markdown was not expressive enough in the past (without mdx). mdx has already solved the lack of expressiveness (via JSX syntax), so there is no need to support HTML syntax.
77+
78+
The removing of html comment syntax does bring some migration costs. You can quickly migrate it by regular search and replacement: `<!--(.*?)-->` replace to `{/*$0*/}`.
79+
6980
## Use Node.js ECMAScript modules
7081

7182
The Node.js community is quickly migrating from CommonJS to ECMAScript modules (esm). And we encourage you to run vite on the esm mode of Node.js.

0 commit comments

Comments
 (0)