diff --git a/packages/@vuepress/core/lib/node/App.js b/packages/@vuepress/core/lib/node/App.js index 87f78438b4..8684b652fe 100755 --- a/packages/@vuepress/core/lib/node/App.js +++ b/packages/@vuepress/core/lib/node/App.js @@ -149,12 +149,12 @@ module.exports = class App { .use(require('./internal-plugins/transformModule')) .use(require('./internal-plugins/dataBlock')) .use(require('./internal-plugins/frontmatterBlock')) - .use('@vuepress/container', { + .use('container', { type: 'slot', before: info => `' }) - .use('@vuepress/container', { + .use('container', { type: 'v-pre', before: '
', after: '
' diff --git a/packages/@vuepress/core/package.json b/packages/@vuepress/core/package.json index 168125b1ca..a8b8fccbf6 100644 --- a/packages/@vuepress/core/package.json +++ b/packages/@vuepress/core/package.json @@ -33,7 +33,6 @@ "@vue/babel-preset-app": "^3.1.1", "@vuepress/markdown": "^1.0.0-alpha.44", "@vuepress/markdown-loader": "^1.0.0-alpha.44", - "@vuepress/plugin-container": "^1.0.0-alpha.44", "@vuepress/plugin-last-updated": "^1.0.0-alpha.44", "@vuepress/plugin-register-components": "^1.0.0-alpha.44", "@vuepress/shared-utils": "^1.0.0-alpha.44", @@ -60,6 +59,7 @@ "vue-server-renderer": "^2.5.16", "vue-template-compiler": "^2.5.16", "vuepress-html-webpack-plugin": "^3.2.0", + "vuepress-plugin-container": "^2.0.0", "webpack": "^4.8.1", "webpack-chain": "^4.6.0", "webpack-dev-server": "^3.1.14", diff --git a/packages/@vuepress/plugin-container/.npmignore b/packages/@vuepress/plugin-container/.npmignore deleted file mode 100644 index 13c38ea313..0000000000 --- a/packages/@vuepress/plugin-container/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -__tests__ -__mocks__ -.temp diff --git a/packages/@vuepress/plugin-container/README.md b/packages/@vuepress/plugin-container/README.md deleted file mode 100644 index a7910b2df6..0000000000 --- a/packages/@vuepress/plugin-container/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# @vuepress/plugin-container - -> markdown container plugin for vuepress - -See [documentation](https://v1.vuepress.vuejs.org/plugin/official/plugin-container.html). diff --git a/packages/@vuepress/plugin-container/__tests__/__snapshots__/index.spec.js.snap b/packages/@vuepress/plugin-container/__tests__/__snapshots__/index.spec.js.snap deleted file mode 100644 index f67ad8f0a6..0000000000 --- a/packages/@vuepress/plugin-container/__tests__/__snapshots__/index.spec.js.snap +++ /dev/null @@ -1,48 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`containers danger.md 1`] = ` -
-

DANGER

-

I am a danger

-
-`; - -exports[`containers markdown-slots.md 1`] = ` - - - -`; - -exports[`containers tip.md 1`] = ` -
-

TIP

-

I am a tip

-
-`; - -exports[`containers tip-override.md 1`] = ` -
-

提示

-

I am a tip

-
-`; - -exports[`containers v-pre.md 1`] = ` -
-

I am a v-pre

-
-`; - -exports[`containers warning.md 1`] = ` -
-

WARNING

-

I am a warning

-
-`; diff --git a/packages/@vuepress/plugin-container/__tests__/fragments/danger.md b/packages/@vuepress/plugin-container/__tests__/fragments/danger.md deleted file mode 100644 index 2f2aa62ca6..0000000000 --- a/packages/@vuepress/plugin-container/__tests__/fragments/danger.md +++ /dev/null @@ -1,3 +0,0 @@ -::: danger -I am a danger -::: diff --git a/packages/@vuepress/plugin-container/__tests__/fragments/markdown-slots.md b/packages/@vuepress/plugin-container/__tests__/fragments/markdown-slots.md deleted file mode 100644 index c6c60ab812..0000000000 --- a/packages/@vuepress/plugin-container/__tests__/fragments/markdown-slots.md +++ /dev/null @@ -1,10 +0,0 @@ -::: slot header -# Here might be a page title -::: - -- A Paragraph -- Another Paragraph - -::: slot footer -Here's some contact info -::: diff --git a/packages/@vuepress/plugin-container/__tests__/fragments/tip-override.md b/packages/@vuepress/plugin-container/__tests__/fragments/tip-override.md deleted file mode 100644 index 2ba47c3859..0000000000 --- a/packages/@vuepress/plugin-container/__tests__/fragments/tip-override.md +++ /dev/null @@ -1,3 +0,0 @@ -::: tip 提示 -I am a tip -::: diff --git a/packages/@vuepress/plugin-container/__tests__/fragments/tip.md b/packages/@vuepress/plugin-container/__tests__/fragments/tip.md deleted file mode 100644 index e9b82b19fd..0000000000 --- a/packages/@vuepress/plugin-container/__tests__/fragments/tip.md +++ /dev/null @@ -1,3 +0,0 @@ -::: tip -I am a tip -::: diff --git a/packages/@vuepress/plugin-container/__tests__/fragments/v-pre.md b/packages/@vuepress/plugin-container/__tests__/fragments/v-pre.md deleted file mode 100644 index f1694023b7..0000000000 --- a/packages/@vuepress/plugin-container/__tests__/fragments/v-pre.md +++ /dev/null @@ -1,3 +0,0 @@ -::: v-pre -I am a v-pre -::: diff --git a/packages/@vuepress/plugin-container/__tests__/fragments/warning.md b/packages/@vuepress/plugin-container/__tests__/fragments/warning.md deleted file mode 100644 index 37aa641bc0..0000000000 --- a/packages/@vuepress/plugin-container/__tests__/fragments/warning.md +++ /dev/null @@ -1,3 +0,0 @@ -::: warning -I am a warning -::: diff --git a/packages/@vuepress/plugin-container/__tests__/index.spec.js b/packages/@vuepress/plugin-container/__tests__/index.spec.js deleted file mode 100644 index b1efaa9911..0000000000 --- a/packages/@vuepress/plugin-container/__tests__/index.spec.js +++ /dev/null @@ -1,36 +0,0 @@ -const { createApp } = require('@vuepress/core') -const { getFragments } = require('@vuepress/test-utils') -import containerPlugin from '..' - -describe('containers', async () => { - let app - - beforeAll(async () => { - app = createApp() - app.options.siteConfig = { - plugins: [ - [containerPlugin, { type: 'tip' }], - [containerPlugin, { type: 'warning' }], - [containerPlugin, { type: 'danger' }], - [containerPlugin, { - type: 'slot', - before: info => `' - }], - [containerPlugin, { - type: 'v-pre', - before: '
', - after: '
' - }] - ] - } - return app.process() - }) - - getFragments(__dirname).forEach(({ name, content: input }) => { - test(name, () => { - const { html } = app.markdown.render(input) - expect(html).toMatchSnapshot() - }) - }) -}) diff --git a/packages/@vuepress/plugin-container/index.js b/packages/@vuepress/plugin-container/index.js deleted file mode 100644 index 6d995b4bed..0000000000 --- a/packages/@vuepress/plugin-container/index.js +++ /dev/null @@ -1,50 +0,0 @@ -const container = require('markdown-it-container') - -function call (target, ...args) { - if (typeof target === 'function') { - return target(...args) - } else { - return target - } -} - -module.exports = (options, context) => ({ - name: require('./package').name, - - multiple: true, - - extendMarkdown (md) { - const { - validate, - marker, - before, - after, - type = '', - defaultTitle = type.toUpperCase() - } = options - if (!type) return - - let { render } = options - if (!render) { - if (before !== undefined && after !== undefined) { - render = (tokens, index) => { - const info = tokens[index].info.trim().slice(type.length).trim() - return tokens[index].nesting === 1 ? call(before, info) : call(after, info) - } - } else { - render = (tokens, index) => { - const token = tokens[index] - let title = token.info.trim().slice(type.length).trim() || defaultTitle - if (title) title = `

${title}

` - if (token.nesting === 1) { - return `
${title}\n` - } else { - return `
\n` - } - } - } - } - - md.use(container, type, { render, validate, marker }) - } -}) diff --git a/packages/@vuepress/plugin-container/package.json b/packages/@vuepress/plugin-container/package.json deleted file mode 100644 index f148970595..0000000000 --- a/packages/@vuepress/plugin-container/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "@vuepress/plugin-container", - "version": "1.0.0-alpha.44", - "description": "markdown container plugin for vuepress", - "main": "index.js", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/vuejs/vuepress.git", - "directory": "packages/@vuepress/plugin-container" - }, - "keywords": [ - "documentation", - "vue", - "vuepress", - "generator" - ], - "dependencies": { - "markdown-it-container": "^2.0.0" - }, - "devDependencies": { - "@vuepress/test-utils": "^1.0.0-alpha.44" - }, - "author": "Shigma <1700011071@pku.edu.cn>", - "license": "MIT", - "bugs": { - "url": "https://github.com/vuejs/vuepress/issues" - }, - "homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/plugin-container#readme" -} diff --git a/packages/@vuepress/theme-default/index.js b/packages/@vuepress/theme-default/index.js index 0bf3d1e892..f6caeda714 100644 --- a/packages/@vuepress/theme-default/index.js +++ b/packages/@vuepress/theme-default/index.js @@ -21,8 +21,23 @@ module.exports = (options, ctx) => ({ '@vuepress/active-header-links', '@vuepress/search', '@vuepress/plugin-nprogress', - ['@vuepress/container', { type: 'tip' }], - ['@vuepress/container', { type: 'warning' }], - ['@vuepress/container', { type: 'danger' }] + ['container', { + type: 'tip', + defaultTitle: { + '/zh/': '提示' + } + }], + ['container', { + type: 'warning', + defaultTitle: { + '/zh/': '注意' + } + }], + ['container', { + type: 'danger', + defaultTitle: { + '/zh/': '警告' + } + }] ] }) diff --git a/packages/@vuepress/theme-default/package.json b/packages/@vuepress/theme-default/package.json index 186907524e..316a57e33a 100644 --- a/packages/@vuepress/theme-default/package.json +++ b/packages/@vuepress/theme-default/package.json @@ -31,11 +31,11 @@ "homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/theme-default#readme", "dependencies": { "@vuepress/plugin-active-header-links": "^1.0.0-alpha.44", - "@vuepress/plugin-container": "^1.0.0-alpha.44", "@vuepress/plugin-nprogress": "^1.0.0-alpha.44", "@vuepress/plugin-search": "^1.0.0-alpha.44", "docsearch.js": "^2.5.2", "stylus": "^0.54.5", - "stylus-loader": "^3.0.2" + "stylus-loader": "^3.0.2", + "vuepress-plugin-container": "^2.0.0" } } diff --git a/packages/docs/docs/.vuepress/config.js b/packages/docs/docs/.vuepress/config.js index 37ab4d78ad..63158b8e30 100755 --- a/packages/docs/docs/.vuepress/config.js +++ b/packages/docs/docs/.vuepress/config.js @@ -74,12 +74,12 @@ module.exports = ctx => ({ ['@vuepress/google-analytics', { ga: 'UA-128189152-1' }], - ['@vuepress/container', { + ['container', { type: 'vue', before: '
',
       after: '
', }], - ['@vuepress/container', { + ['container', { type: 'upgrade', before: info => ``, after: '', diff --git a/packages/docs/docs/guide/markdown.md b/packages/docs/docs/guide/markdown.md index f6ab0cb99f..c6a31b3c5a 100644 --- a/packages/docs/docs/guide/markdown.md +++ b/packages/docs/docs/guide/markdown.md @@ -167,7 +167,7 @@ Danger zone, do not proceed **Also see:** -- [@vuepress/plugin-container](../plugin/official/plugin-container.md) +- [vuepress-plugin-container](https://vuepress.github.io/plugins/container/) ## Syntax Highlighting in Code Blocks diff --git a/packages/docs/docs/plugin/official/plugin-container.md b/packages/docs/docs/plugin/official/plugin-container.md deleted file mode 100644 index 0ee876ef7c..0000000000 --- a/packages/docs/docs/plugin/official/plugin-container.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: container -metaTitle: A plugin for registering markdown containers | VuePress ---- - -# [@vuepress/plugin-container](https://github.com/vuejs/vuepress/tree/master/packages/@vuepress/plugin-container) - -> A plugin for registering markdown containers, based on [markdown-it-container](https://github.com/markdown-it/markdown-it-container). - -## Install - -```bash -yarn add -D @vuepress/plugin-container@next -# OR npm install -D @vuepress/plugin-container@next -``` - -## Usage - -```javascript -module.exports = { - plugins: ['@vuepress/container'] -} -``` - -## Options - -### type - -- Type: `string` -- This is a required option. - -The type for the container. For example, if `type` is set to `foo`, only the following syntax will be parsed as a container: - -```md -::: foo bar -write something here ~ -::: -``` - -### defaultTitle - -- Type: `string` -- Default: the upper case of `type` - -The default title for the container. If no title is provided, `defaultTitle` will be shown as the title of the container. - -### before - -- Type: `string | Function` -- Default: `undefined` - -String to be placed before the block. If specified as a function, an argument `info` will be passed to it. (In the example above, `info` will be `bar`.) If specified, it will override `defaultTitle`. - -### after - -- Type: `string | Function` -- Default: `undefined` - -String to be placed after the block. If specified as a function, an argument `info` will be passed to it. (In the example above, `info` will be `bar`.) If specified, it will override `defaultTitle`. - -### validate - -- Type: `Function` -- Default: `undefined` - -A function to validate tail after opening marker, should return `true` on success. - -### render - -- Type: `Function` -- Default: `undefined` - -The renderer function for opening/closing tokens. If specified, it will override `before`, `after` and `defaultTitle`. - -### marker - -- Type: `string` -- Default: `':'` - -The character to use as a delimiter. diff --git a/packages/docs/docs/zh/guide/markdown.md b/packages/docs/docs/zh/guide/markdown.md index 68307ace16..87253d580a 100644 --- a/packages/docs/docs/zh/guide/markdown.md +++ b/packages/docs/docs/zh/guide/markdown.md @@ -165,7 +165,7 @@ Danger zone, do not proceed **参考:** -- [@vuepress/plugin-container](../plugin/official/plugin-container.md) +- [vuepress-plugin-container](https://vuepress.github.io/plugins/container/) ## 代码块中的语法高亮 diff --git a/packages/docs/docs/zh/plugin/official/plugin-container.md b/packages/docs/docs/zh/plugin/official/plugin-container.md deleted file mode 100644 index 200aeffb8f..0000000000 --- a/packages/docs/docs/zh/plugin/official/plugin-container.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: container -metaTitle: Markdown 容器插件 | VuePress ---- - -# [@vuepress/plugin-container](https://github.com/vuejs/vuepress/tree/master/packages/@vuepress/plugin-container) - -> 用于注册 Markdown 容器的插件,基于 [markdown-it-container](https://github.com/markdown-it/markdown-it-container)。 - -## 安装 - -```bash -yarn add -D @vuepress/plugin-container@next -# OR npm install -D @vuepress/plugin-container@next -``` - -## 使用 - -```javascript -module.exports = { - plugins: ['@vuepress/container'] -} -``` - -## 选项 - -### type - -- 类型: `string` -- 这是一个必需的选项 - -容器的类型。举个例子,如果 `type` 被设置为 `foo`,则仅有下面的语法会被视为对应的容器: - -```md -::: foo bar -随便写点啥 ~ -::: -``` - -### defaultTitle - -- 类型: `string` -- 默认值: `type` 的大写形式 - -容器的默认标题。如果没有提供标题,则会使用 `defaultTitle` 作为容器的标题。 - -### before - -- 类型: `string | Function` -- 默认值: `undefined` - -要插入在容器前的 HTML。如果设置为一个函数,将传入当前的 `info` 作为第一个参数。(在上面的例子中,`info` 的值为 `bar`。)如果设置了这个值,它将覆盖 `defaultTitle` 的效果。 - -### after - -- 类型: `string | Function` -- 默认值: `undefined` - -要插入在容器后的 HTML。如果设置为一个函数,将传入当前的 `info` 作为第一个参数。(在上面的例子中,`info` 的值为 `bar`。)如果设置了这个值,它将覆盖 `defaultTitle` 的效果。 - -### validate - -- 类型: `Function` -- 默认值: `undefined` - -一个用于判定容器是否结束的函数。当认定容器范围结束时应返回一个 `true`。 - -### render - -- 类型: `Function` -- 默认值: `undefined` - -容器开头和结束 token 的渲染函数。如果设置了这个值,它将覆盖 `before`, `after` 和 `defaultTitle` 的效果。 - -### marker - -- 类型: `string` -- 默认值: `':'` - -用于分隔符的字符。 diff --git a/packages/docs/docs/zh/theme/default-theme-config.md b/packages/docs/docs/zh/theme/default-theme-config.md index b31f25674f..8516cf5fe0 100644 --- a/packages/docs/docs/zh/theme/default-theme-config.md +++ b/packages/docs/docs/zh/theme/default-theme-config.md @@ -1,6 +1,6 @@ # 默认主题配置 -::: tip 提示 +::: tip 本页所列的选项仅对默认主题生效。如果你在使用一个自定义主题,选项可能会有不同。 ::: diff --git a/packages/docs/docs/zh/theme/using-a-theme.md b/packages/docs/docs/zh/theme/using-a-theme.md index 2c4f729db8..e6b7f3c517 100644 --- a/packages/docs/docs/zh/theme/using-a-theme.md +++ b/packages/docs/docs/zh/theme/using-a-theme.md @@ -46,6 +46,6 @@ module.exports = { } ``` -::: warning 注意 +::: warning 以 `@vuepress/theme-` 开头的主题是官方维护的主题。 ::: diff --git a/yarn.lock b/yarn.lock index c9ecbad567..8ede542419 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9567,6 +9567,13 @@ vuepress-html-webpack-plugin@^3.2.0: toposort "^1.0.0" util.promisify "1.0.0" +vuepress-plugin-container@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/vuepress-plugin-container/-/vuepress-plugin-container-2.0.1.tgz#b20ef97dd91f137c8be119460927c5ffd64e0f77" + integrity sha512-SMlWJl0uZYkqAxD2RUZmIrANZWKgiZdM64K7WmdyHyQPYI+NUj3ugi5D+zDn62BoO9NfQTiskEIa2u619SRweA== + dependencies: + markdown-it-container "^2.0.0" + vuepress-plugin-flowchart@^1.4.2: version "1.4.3" resolved "https://registry.yarnpkg.com/vuepress-plugin-flowchart/-/vuepress-plugin-flowchart-1.4.3.tgz#1692807257c9ba02f764ced0caf930c627f65bdb"