feat: add markdown-it-cjk-friendly

closes #3762
closes #4752

BREAKING CHANGE: [markdown-it-cjk-friendly](https://www.npmjs.com/package/markdown-it-cjk-friendly) is enabled by default. This intentionally deviates from the official commonmark spec for the benefit of CJK users. **For most users, no change is required.** If you were using hacks to patch `scanDelims`, you can remove those. To disable the plugin, set `markdown: { cjkFriendly: false }` in your vitepress config.
v2-theme
Divyansh Singh 2 weeks ago
parent 1c8815d53e
commit 9fc8462726

@ -158,6 +158,7 @@
"markdown-it-anchor": "^9.2.0",
"markdown-it-async": "^2.2.0",
"markdown-it-attrs": "^4.3.1",
"markdown-it-cjk-friendly": "^1.2.0",
"markdown-it-container": "^4.0.0",
"markdown-it-emoji": "^3.0.0",
"markdown-it-mathjax3": "^4.3.2",

File diff suppressed because it is too large Load Diff

@ -22,6 +22,7 @@ import type {
import anchorPlugin from 'markdown-it-anchor'
import { MarkdownItAsync, type Options } from 'markdown-it-async'
import attrsPlugin from 'markdown-it-attrs'
import mditCjkFriendly from 'markdown-it-cjk-friendly'
import { full as emojiPlugin } from 'markdown-it-emoji'
import type { BuiltinLanguage, BuiltinTheme, Highlighter } from 'shiki'
import type { Logger } from 'vite'
@ -188,6 +189,13 @@ export interface MarkdownOptions extends Options {
* @see https://vitepress.dev/guide/markdown#github-flavored-alerts
*/
gfmAlerts?: boolean
/**
* Allows disabling the CJK-friendly plugin.
* This plugin adds support for emphasis marks (**bold**) in Japanese, Chinese, and Korean text.
* @default true
* @see https://github.com/tats-u/markdown-cjk-friendly
*/
cjkFriendly?: boolean
}
export type MarkdownRenderer = MarkdownItAsync
@ -352,6 +360,10 @@ export async function createMarkdownRenderer(
}
}
if (options.cjkFriendly !== false) {
md.use(mditCjkFriendly)
}
// apply user config
if (options.config) {
await options.config(md)

Loading…
Cancel
Save