Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
17 changes: 6 additions & 11 deletions docs/plugins/markdown/markdown-ext.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 `<br>`s.
- Enabled in GFM: Yes
- Details: Whether convert `\n` in paragraphs into `<br>`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.
21 changes: 8 additions & 13 deletions docs/zh/plugins/markdown/markdown-ext.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,13 @@ type: tip
- 脚注
- 任务列表

请注意,一些行为可能和 GitHub Flavored Markdown 不同
请注意:并不是所有行为都与 GitHub Flavored Markdown 完全相同

### footnote

- 类型:`boolean`
- 默认值:`false`
- 详情:是否启用脚注格式支持。
- 在 GFM 中启用:是
- 详情:是否启用页脚格式支持。

### tasklist

Expand All @@ -166,34 +165,30 @@ type: tip
}
```

- 默认值:`false`
- 在 GFM 中启用:是
- 详情:

是否启用任务列表格式支持。您可以传递一个对象来配置任务列表。
是否启用任务列表格式支持。你可以传递一个对象来配置任务列表。

- 在 GFM 中启用:是

### breaks

- 类型:`boolean`
- 默认值:`false`
- 在 GFM 中启用:是
- 详情:是否将段落中的 `\n` 转换为 `<br>`。
- 在 GFM 中启用:是

### linkify

- 类型:`boolean`
- 默认值:`false`
- 在 GFM 中启用:是
- 详情:是否将类似 URL 的文本转换为链接。
- 在 GFM 中启用:是

### component

- 类型:`boolean`
- 默认值:`false`
- 详情:是否启用组件代码块支持。

### vPre

- 类型:`boolean`
- 默认值:`false`
- 详情:是否启用 `v-pre` 块支持。
- 详情:是否启用 v-pre 容器支持。
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
(
Expand Down Expand Up @@ -46,6 +54,11 @@ ${content}
return ''
}

/**
* Component fence support plugin
*
* 组件代码块支持插件
*/
export const component: PluginSimple = (md) => {
// Handle ```component blocks
const { fence } = md.renderer.rules
Expand Down
Original file line number Diff line number Diff line change
@@ -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, '&#39')
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
23 changes: 23 additions & 0 deletions plugins/markdown/plugin-markdown-ext/src/node/markdownExtPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions plugins/markdown/plugin-markdown-ext/src/node/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type { MarkdownItTaskListOptions } from '@mdit/plugin-tasklist'

/**
* Options of markdown-ext plugin
*
* markdown-ext 插件选项
*/
export interface MarkdownExtPluginOptions {
/**
Expand Down
Loading