-
-
Notifications
You must be signed in to change notification settings - Fork 198
Description
What problem does this feature solve?
The plain CommonMark/GFM has a specification defect that bold/emphasis frequently fail in Chinese (or Japanese) text.
**中文文本(带括号)。**这句子继续也没问题。- Expected: 中文文本(带括号)。这句子继续也没问题。
- Actual: **中文文本(带括号)。**这句子继续也没问题。
There are some Remark plugins to suppress this problem as a worksaround (demo), but you have to disable mdxRs first, messing up one of the biggest advantages of Rspress:
import remarkCjkFriendly from "remark-cjk-friendly";
import remarkGfmStrikethroughCjkFriendly from "remark-cjk-friendly-gfm-strikethrough";
import { defineConfig } from "rspress/config";
export default defineConfig({
markdown: {
mdxRs: false, // IMPORTANT! This is mandatory for Rspress!
// Once you turn off `mdxRs`, you can add `remarkPlugins` and `rehypePlugins` like other remark-based site generators.
remarkPlugins: [remarkCjkFriendly, remarkGfmStrikethroughCjkFriendly],
},
});VitePress is going to bundle the markdown-it variant of these plugins and enable it by default since 2.x (still beta now).
What does the proposed API look like?
If opt-out like VitePress:
import { defineConfig } from "rspress/config";
export default defineConfig({
markdown: {
cjkFriendlyEmphasis: false, // If you want to disable it for some reson
},
});The most difficult point is that we have to fork and modify the markdown(-rs) crate first because it will not support extensions other than the most popular ones. The comrak crate has implemented this extension so we can reuse its implementation as a Rust-based model implementation.
This extension is compatible with the plain CommonMark/GFM except for emphasis/strikethrough handling for CJK characters.