Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(markdown): remove codePlugin and add vPrePlugin (close #1550) #1556

Merged
merged 13 commits into from
May 27, 2024
17 changes: 13 additions & 4 deletions packages/markdown/src/markdown.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { slugify as defaultSlugify } from '@mdit-vue/shared'
import { logger } from '@vuepress/utils'
import MarkdownIt from 'markdown-it'
import {
anchorPlugin,
assetsPlugin,
codePlugin,
componentPlugin,
emojiPlugin,
frontmatterPlugin,
Expand All @@ -13,18 +13,19 @@ import {
sfcPlugin,
titlePlugin,
tocPlugin,
vPrePlugin,
} from './plugins.js'
import type {
AnchorPluginOptions,
AssetsPluginOptions,
CodePluginOptions,
EmojiPluginOptions,
FrontmatterPluginOptions,
HeadersPluginOptions,
ImportCodePluginOptions,
LinksPluginOptions,
SfcPluginOptions,
TocPluginOptions,
VPrePluginOptions,
} from './plugins.js'
import type { Markdown, MarkdownOptions } from './types.js'

Expand All @@ -35,6 +36,7 @@ export const createMarkdown = ({
anchor,
assets,
code,
vPre,
component,
emoji,
frontmatter,
Expand Down Expand Up @@ -82,8 +84,15 @@ export const createMarkdown = ({
}

// process code fence
if (code !== false) {
md.use<CodePluginOptions>(codePlugin, code)
if (code) {
logger.warn(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we updated the docs? Or maybe we need to link to plugin docs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I will open a pr for this, note a route related pr is open a few days ago not not being merged.

`\`markdown.code\` option has been removed, please use '@vuepress/plugin-shiki' or '@vuepress/plugin-prismjs' instead.\n See https://v2.vuepress.vuejs.org/reference/config.html#markdown-code`,
)
}

// add v-pre to `<pre>` and `<code>`
if (vPre !== false) {
md.use<VPrePluginOptions>(vPrePlugin, vPre)
}

// treat unknown html tags as components
Expand Down
8 changes: 4 additions & 4 deletions packages/markdown/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export {
assetsPlugin,
type AssetsPluginOptions,
} from './plugins/assetsPlugin/assetsPlugin.js'
export {
codePlugin,
type CodePluginOptions,
} from './plugins/codePlugin/codePlugin.js'
export { emojiPlugin, type EmojiPluginOptions } from './plugins/emojiPlugin.js'
export {
importCodePlugin,
Expand All @@ -35,3 +31,7 @@ export {
linksPlugin,
type LinksPluginOptions,
} from './plugins/linksPlugin/linksPlugin.js'
export {
vPrePlugin,
type VPrePluginOptions,
} from './plugins/vPrePlugin/vPrePlugin.js'
151 changes: 0 additions & 151 deletions packages/markdown/src/plugins/codePlugin/codePlugin.ts

This file was deleted.

105 changes: 0 additions & 105 deletions packages/markdown/src/plugins/codePlugin/languages.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/markdown/src/plugins/codePlugin/resolveAttr.ts

This file was deleted.

34 changes: 0 additions & 34 deletions packages/markdown/src/plugins/codePlugin/resolveHighlightLines.ts

This file was deleted.

Loading
Loading