From 24a1e69e389153bca499958ea5b15de3fc0ad33d Mon Sep 17 00:00:00 2001
From: Shigma <1700011071@pku.edu.cn>
Date: Sun, 24 Feb 2019 19:17:11 +0800
Subject: [PATCH 1/4] initial commit
---
.../@vuepress/plugin-container/.npmignore | 3 ++
packages/@vuepress/plugin-container/README.md | 5 ++++
packages/@vuepress/plugin-container/index.js | 14 +++++++++
.../@vuepress/plugin-container/package.json | 29 +++++++++++++++++++
4 files changed, 51 insertions(+)
create mode 100644 packages/@vuepress/plugin-container/.npmignore
create mode 100644 packages/@vuepress/plugin-container/README.md
create mode 100644 packages/@vuepress/plugin-container/index.js
create mode 100644 packages/@vuepress/plugin-container/package.json
diff --git a/packages/@vuepress/plugin-container/.npmignore b/packages/@vuepress/plugin-container/.npmignore
new file mode 100644
index 0000000000..13c38ea313
--- /dev/null
+++ b/packages/@vuepress/plugin-container/.npmignore
@@ -0,0 +1,3 @@
+__tests__
+__mocks__
+.temp
diff --git a/packages/@vuepress/plugin-container/README.md b/packages/@vuepress/plugin-container/README.md
new file mode 100644
index 0000000000..fc0b2211d2
--- /dev/null
+++ b/packages/@vuepress/plugin-container/README.md
@@ -0,0 +1,5 @@
+# @vuepress/plugin-container
+
+> markdown container plugin for vuepress
+
+See [documentation](https://vuepress.vuejs.org/plugin/official/plugin-container.html).
diff --git a/packages/@vuepress/plugin-container/index.js b/packages/@vuepress/plugin-container/index.js
new file mode 100644
index 0000000000..7c45b47210
--- /dev/null
+++ b/packages/@vuepress/plugin-container/index.js
@@ -0,0 +1,14 @@
+const container = require('markdown-it-container')
+
+module.exports = (options = {}, context) => ({
+ name: 'container',
+ multiple: true,
+
+ extendMarkdown: md => {
+ md.use(container, 'v-pre', {
+ render: (tokens, idx) => tokens[idx].nesting === 1
+ ? `
${title}
\n`
+ return `
${title}\n`
} else {
return `
\n`
}
diff --git a/packages/docs/docs/.vuepress/config.js b/packages/docs/docs/.vuepress/config.js
index 46b8498a66..e1a7e0466a 100755
--- a/packages/docs/docs/.vuepress/config.js
+++ b/packages/docs/docs/.vuepress/config.js
@@ -1,3 +1,5 @@
+const { fs, path } = require('@vuepress/shared-utils')
+
module.exports = ctx => ({
dest: '../../vuepress',
locales: {
@@ -115,6 +117,10 @@ function getGuideSidebar (groupA, groupB) {
]
}
+const officalPlugins = fs
+ .readdirSync(path.resolve(__dirname, '../plugin/official'))
+ .map(filename => 'official/' + filename.slice(0, -3))
+
function getPluginSidebar (pluginTitle, pluginIntro, officialPluginTitle) {
return [
{
@@ -132,20 +138,7 @@ function getPluginSidebar (pluginTitle, pluginIntro, officialPluginTitle) {
{
title: officialPluginTitle,
collapsable: false,
- children: [
- 'official/plugin-search',
- 'official/plugin-active-header-links',
- 'official/plugin-pwa',
- 'official/plugin-blog',
- 'official/plugin-pagination',
- 'official/plugin-google-analytics',
- 'official/plugin-i18n-ui',
- 'official/plugin-last-updated',
- 'official/plugin-medium-zoom',
- 'official/plugin-back-to-top',
- 'official/plugin-register-components',
- 'official/plugin-clean-urls'
- ]
+ children: officalPlugins,
}
]
}
diff --git a/packages/docs/docs/plugin/official/plugin-container.md b/packages/docs/docs/plugin/official/plugin-container.md
new file mode 100644
index 0000000000..359f3a98cf
--- /dev/null
+++ b/packages/docs/docs/plugin/official/plugin-container.md
@@ -0,0 +1,80 @@
+---
+title: container
+metaTitle: A plugin of registering markdown containers | VuePress
+---
+
+# [@vuepress/plugin-container](https://github.com/vuejs/vuepress/tree/master/packages/@vuepress/plugin-container)
+
+> A plugin of registering markdown containers
+
+## Install
+
+```bash
+yarn add -D @vuepress/plugin-container
+# OR npm install -D @vuepress/plugin-container
+```
+
+## 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` was 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 was provided, `defaultTitle` will be showed as the title of the container.
+
+### before
+
+- Type: `string | Function`
+- Default: `undefined`
+
+String to be placed before the block. If specified as a function, a argument `token` will be passed to it. If specified, it will override `defaultTitle`.
+
+### after
+
+- Type: `string | Function`
+- Default: `undefined`
+
+String to be placed after the block. If specified as a function, a argument `token` will be passed to it. 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 in delimiter.
diff --git a/packages/docs/docs/zh/plugin/official/plugin-container.md b/packages/docs/docs/zh/plugin/official/plugin-container.md
new file mode 100644
index 0000000000..ed29cccc7a
--- /dev/null
+++ b/packages/docs/docs/zh/plugin/official/plugin-container.md
@@ -0,0 +1,80 @@
+---
+title: container
+metaTitle: Markdown 容器插件 | VuePress
+---
+
+# [@vuepress/plugin-container](https://github.com/vuejs/vuepress/tree/master/packages/@vuepress/plugin-container)
+
+> Markdown 容器插件
+
+## 安装
+
+```bash
+yarn add -D @vuepress/plugin-container
+# OR npm install -D @vuepress/plugin-container
+```
+
+## 使用
+
+```javascript
+module.exports = {
+ plugins: ['@vuepress/container']
+}
+```
+
+## 选项
+
+### type
+
+- 类型: `string`
+- 这是一个必需的选项
+
+容器的类型。举个例子,如果 `type` 被设置为 `foo`,则仅有下面的语法会被视为对应的容器:
+
+```md
+::: foo bar
+随便写点啥 ~
+:::
+```
+
+### defaultTitle
+
+- 类型: `string`
+- 默认值: `type` 的大写形式
+
+容器的默认标题。如果没有提供标题,则会使用 `defaultTitle` 作为容器的标题。
+
+### before
+
+- 类型: `string | Function`
+- 默认值: `undefined`
+
+要插入在容器前的 HTML。如果设置为一个函数,将传入当前的 `token` 作为第一个参数。如果设置了这个值,它将覆盖 `defaultTitle` 的效果。
+
+### after
+
+- 类型: `string | Function`
+- 默认值: `undefined`
+
+要插入在容器后的 HTML。如果设置为一个函数,将传入当前的 `token` 作为第一个参数。如果设置了这个值,它将覆盖 `defaultTitle` 的效果。
+
+### validate
+
+- 类型: `Function`
+- 默认值: `undefined`
+
+一个用于判定容器是否结束的函数。当认定容器范围结束时应返回一个 `true`。
+
+### render
+
+- 类型: `Function`
+- 默认值: `undefined`
+
+容器开头和结束 token 的渲染函数。如果设置了这个值,它将覆盖 `before`, `after` 和 `defaultTitle` 的效果。
+
+### marker
+
+- 类型: `string`
+- 默认值: `':'`
+
+用于分隔符的字符。
From 6b3a34b5248cb733736894e6398f913f3c05d864 Mon Sep 17 00:00:00 2001
From: Shigma <1700011071@pku.edu.cn>
Date: Sat, 2 Mar 2019 23:39:58 +0800
Subject: [PATCH 4/4] remove markdown-it-container from @vuepress/markdown
---
packages/@vuepress/markdown/package.json | 1 -
1 file changed, 1 deletion(-)
diff --git a/packages/@vuepress/markdown/package.json b/packages/@vuepress/markdown/package.json
index 196639d6ba..14607ebad2 100644
--- a/packages/@vuepress/markdown/package.json
+++ b/packages/@vuepress/markdown/package.json
@@ -24,7 +24,6 @@
"markdown-it": "^8.4.1",
"markdown-it-anchor": "^5.0.2",
"markdown-it-chain": "^1.3.0",
- "markdown-it-container": "^2.0.0",
"markdown-it-emoji": "^1.4.0",
"markdown-it-table-of-contents": "^0.4.0",
"prismjs": "^1.13.0"