diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 819e507c74..dc5b5d4ba7 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -106,4 +106,4 @@ Each option in plugin/theme documentation must include: - English: "Default: `defaultValue`" - Chinese: "默认值:`defaultValue`" - **Reference**: Optional, links to relevant documentation (always as list) -- **Details**: Brief description of purpose/usage, prefer paragraph for long contents. +- **Details**: Brief description of purpose/usage, prefer same line for short contents and paragraph for long contents. diff --git a/docs/plugins/markdown/markdown-ext.md b/docs/plugins/markdown/markdown-ext.md index 6120b7d8d9..76589af9d6 100644 --- a/docs/plugins/markdown/markdown-ext.md +++ b/docs/plugins/markdown/markdown-ext.md @@ -140,9 +140,8 @@ You can use any mustache syntax as raw text in `v-pre` container: ### footnote - Type: `boolean` -- Default: `false` -- Enabled in GFM: Yes - Details: Whether to enable footnote format support. +- Enabled in GFM: Yes ### tasklist @@ -166,34 +165,30 @@ You can use any mustache syntax as raw text in `v-pre` container: } ``` -- Default: `false` -- Enabled in GFM: Yes - Details: Whether to enable tasklist format support. You can pass an object to config tasklist. +- Enabled in GFM: Yes + ### breaks - Type: `boolean` -- Default: `false` +- Details: Whether convert `\n` in paragraphs into `
`s. - Enabled in GFM: Yes -- Details: Whether convert `\n` in paragraphs into `
`s ### linkify - Type: `boolean` -- Default: `false` +- Details: Whether convert URL-like text into links. - Enabled in GFM: Yes -- Details: Whether convert URL-like text into links ### component - Type: `boolean` -- Default: `false` -- Details: Whether to enable component fence support +- Details: Whether to enable component fence support. ### vPre - Type: `boolean` -- Default: `false` - Details: Whether to enable v-pre wrapper. diff --git a/docs/zh/plugins/markdown/markdown-ext.md b/docs/zh/plugins/markdown/markdown-ext.md index 4799d756ff..3caec8fec9 100644 --- a/docs/zh/plugins/markdown/markdown-ext.md +++ b/docs/zh/plugins/markdown/markdown-ext.md @@ -135,14 +135,13 @@ type: tip - 脚注 - 任务列表 - 请注意,一些行为可能和 GitHub Flavored Markdown 不同。 + 请注意:并不是所有行为都与 GitHub Flavored Markdown 完全相同。 ### footnote - 类型:`boolean` -- 默认值:`false` +- 详情:是否启用脚注格式支持。 - 在 GFM 中启用:是 -- 详情:是否启用页脚格式支持。 ### tasklist @@ -166,34 +165,30 @@ type: tip } ``` -- 默认值:`false` -- 在 GFM 中启用:是 - 详情: - 是否启用任务列表格式支持。您可以传递一个对象来配置任务列表。 + 是否启用任务列表格式支持。你可以传递一个对象来配置任务列表。 + +- 在 GFM 中启用:是 ### breaks - 类型:`boolean` -- 默认值:`false` -- 在 GFM 中启用:是 - 详情:是否将段落中的 `\n` 转换为 `
`。 +- 在 GFM 中启用:是 ### linkify - 类型:`boolean` -- 默认值:`false` -- 在 GFM 中启用:是 - 详情:是否将类似 URL 的文本转换为链接。 +- 在 GFM 中启用:是 ### component - 类型:`boolean` -- 默认值:`false` - 详情:是否启用组件代码块支持。 ### vPre - 类型:`boolean` -- 默认值:`false` -- 详情:是否启用 `v-pre` 块支持。 +- 详情:是否启用 v-pre 容器支持。 diff --git a/plugins/markdown/plugin-markdown-ext/src/node/markdown-it-plugins/component.ts b/plugins/markdown/plugin-markdown-ext/src/node/markdown-it-plugins/component.ts index b476a313fd..287dcdfbc9 100644 --- a/plugins/markdown/plugin-markdown-ext/src/node/markdown-it-plugins/component.ts +++ b/plugins/markdown/plugin-markdown-ext/src/node/markdown-it-plugins/component.ts @@ -7,6 +7,14 @@ import type { MarkdownEnv } from 'vuepress/markdown' import { logger } from '../utils.js' import { stringifyProp } from './utils.js' +/** + * Get component render function + * + * 获取组件渲染函数 + * + * @param name - Component name / 组件名称 + * @returns Render function / 渲染函数 + */ const getComponentRender = (name: string): RenderRule => ( @@ -46,6 +54,11 @@ ${content} return '' } +/** + * Component fence support plugin + * + * 组件代码块支持插件 + */ export const component: PluginSimple = (md) => { // Handle ```component blocks const { fence } = md.renderer.rules diff --git a/plugins/markdown/plugin-markdown-ext/src/node/markdown-it-plugins/utils.ts b/plugins/markdown/plugin-markdown-ext/src/node/markdown-it-plugins/utils.ts index b78742555e..2aa5c60a63 100644 --- a/plugins/markdown/plugin-markdown-ext/src/node/markdown-it-plugins/utils.ts +++ b/plugins/markdown/plugin-markdown-ext/src/node/markdown-it-plugins/utils.ts @@ -1,3 +1,15 @@ +/** + * Stringify prop data for Vue components + * + * 为 Vue 组件字符化属性数据 + * + * @description Single quote will break @vue/compiler-sfc + * + * 单引号会破坏 @vue/compiler-sfc + * + * @param data - Data to stringify / 要字符化的数据 + * @returns Stringified data / 字符化后的数据 + */ // Single quote will break @vue/compiler-sfc export const stringifyProp = (data: unknown): string => JSON.stringify(data).replace(/'/g, ''') diff --git a/plugins/markdown/plugin-markdown-ext/src/node/markdown-it-plugins/vPre.ts b/plugins/markdown/plugin-markdown-ext/src/node/markdown-it-plugins/vPre.ts index 0b46ac88dc..01b3186611 100644 --- a/plugins/markdown/plugin-markdown-ext/src/node/markdown-it-plugins/vPre.ts +++ b/plugins/markdown/plugin-markdown-ext/src/node/markdown-it-plugins/vPre.ts @@ -1,6 +1,11 @@ import { container } from '@mdit/plugin-container' import type { PluginSimple } from 'markdown-it' +/** + * v-pre container support plugin + * + * v-pre 容器支持插件 + */ export const vPre: PluginSimple = (md) => { container(md, { name: 'v-pre', diff --git a/plugins/markdown/plugin-markdown-ext/src/node/markdownExtPlugin.ts b/plugins/markdown/plugin-markdown-ext/src/node/markdownExtPlugin.ts index 47734e84ea..4ab749a6c2 100644 --- a/plugins/markdown/plugin-markdown-ext/src/node/markdownExtPlugin.ts +++ b/plugins/markdown/plugin-markdown-ext/src/node/markdownExtPlugin.ts @@ -11,6 +11,29 @@ import type { MarkdownExtPluginOptions } from './options.js' import { prepareClientConfigFile } from './prepreClientConfigFile.js' import { PLUGIN_NAME } from './utils.js' +/** + * Markdown extensions plugin + * + * Markdown 扩展插件 + * + * @param options - Plugin options / 插件选项 + * @returns VuePress plugin / VuePress 插件 + * + * @example + * ```ts + * import { markdownExtPlugin } from '@vuepress/plugin-markdown-ext' + * + * export default { + * plugins: [ + * markdownExtPlugin({ + * gfm: true, + * component: true, + * vPre: true, + * }), + * ], + * } + * ``` + */ export const markdownExtPlugin = ({ gfm, breaks, diff --git a/plugins/markdown/plugin-markdown-ext/src/node/options.ts b/plugins/markdown/plugin-markdown-ext/src/node/options.ts index 984369d657..2fe91c739b 100644 --- a/plugins/markdown/plugin-markdown-ext/src/node/options.ts +++ b/plugins/markdown/plugin-markdown-ext/src/node/options.ts @@ -2,6 +2,8 @@ import type { MarkdownItTaskListOptions } from '@mdit/plugin-tasklist' /** * Options of markdown-ext plugin + * + * markdown-ext 插件选项 */ export interface MarkdownExtPluginOptions { /**