From 53c84b39724b31ddd76fbe6a9327a6fca922cca0 Mon Sep 17 00:00:00 2001 From: ULIVZ <472590061@qq.com> Date: Thu, 27 Sep 2018 01:14:51 +0800 Subject: [PATCH] refactor($core): separate markdown and markdown-loader from core --- packages/@vuepress/core/lib/dev.js | 2 +- .../@vuepress/core/lib/prepare/AppContext.js | 5 +- packages/@vuepress/core/lib/prepare/Page.js | 6 +- .../core/lib/prepare/createMarkdown.js | 33 ++++++++ packages/@vuepress/core/lib/util/index.js | 65 ---------------- .../core/lib/webpack/createBaseConfig.js | 2 +- packages/@vuepress/core/package.json | 14 +--- packages/@vuepress/markdown-loader/.npmignore | 2 + packages/@vuepress/markdown-loader/README.md | 24 ++++++ .../index.js} | 19 +++-- .../@vuepress/markdown-loader/package.json | 29 +++++++ packages/@vuepress/markdown/.npmignore | 2 + packages/@vuepress/markdown/README.md | 3 + .../__snapshots__/containers.spec.js.snap | 0 .../__snapshots__/highlight.spec.js.snap | 0 .../__snapshots__/highlightLines.spec.js.snap | 0 .../__snapshots__/hoist.spec.js.snap | 0 .../__snapshots__/lineNumers.spec.js.snap | 0 .../__snapshots__/link.spec.js.snap | 0 .../__snapshots__/snippet.spec.js.snap | 0 .../__tests__}/containers.spec.js | 2 +- .../fragments/code-highlightLines-multiple.md | 0 .../fragments/code-highlightLines-single.md | 0 .../code-snippet-highlightLines-multiple.md | 0 .../code-snippet-highlightLines-single.md | 0 .../__tests__}/fragments/code-snippet.md | 0 .../__tests__}/fragments/code.md | 0 .../__tests__}/fragments/container-danger.md | 0 .../fragments/container-tip-override.md | 0 .../__tests__}/fragments/container-tip.md | 0 .../__tests__}/fragments/container-v-pre.md | 0 .../__tests__}/fragments/container-warning.md | 0 .../__tests__}/fragments/hoist.md | 0 .../__tests__}/fragments/snippet.js | 0 .../__tests__}/highlight.spec.js | 2 +- .../__tests__}/highlightLines.spec.js | 2 +- .../__tests__}/hoist.spec.js | 4 +- .../__tests__}/lineNumers.spec.js | 6 +- .../__tests__}/link.spec.js | 4 +- .../__tests__}/slugify.spec.js | 2 +- .../__tests__}/snippet.spec.js | 4 +- .../markdown => markdown/__tests__}/util.js | 0 .../markdown => markdown/lib}/component.js | 0 .../markdown => markdown/lib}/containers.js | 0 .../markdown => markdown/lib}/highlight.js | 3 +- .../lib}/highlightLines.js | 0 .../lib/markdown => markdown/lib}/hoist.js | 0 .../lib/markdown => markdown/lib}/index.js | 76 ++++++++++--------- .../markdown => markdown/lib}/lineNumbers.js | 0 .../lib/markdown => markdown/lib}/link.js | 0 .../markdown => markdown/lib}/preWrapper.js | 0 .../lib/markdown => markdown/lib}/slugify.js | 0 .../lib/markdown => markdown/lib}/snippet.js | 2 +- packages/@vuepress/markdown/package.json | 37 +++++++++ packages/@vuepress/shared-utils/index.js | 10 +++ .../shared-utils/lib/extractHeaders.js | 39 ++++++++++ packages/@vuepress/shared-utils/lib/hash.js | 1 + .../@vuepress/shared-utils/lib/inferTitle.js | 22 ++++++ packages/@vuepress/shared-utils/package.json | 6 +- 59 files changed, 283 insertions(+), 145 deletions(-) create mode 100644 packages/@vuepress/core/lib/prepare/createMarkdown.js create mode 100644 packages/@vuepress/markdown-loader/.npmignore create mode 100644 packages/@vuepress/markdown-loader/README.md rename packages/@vuepress/{core/lib/webpack/markdownLoader.js => markdown-loader/index.js} (91%) create mode 100644 packages/@vuepress/markdown-loader/package.json create mode 100644 packages/@vuepress/markdown/.npmignore create mode 100644 packages/@vuepress/markdown/README.md rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/__snapshots__/containers.spec.js.snap (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/__snapshots__/highlight.spec.js.snap (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/__snapshots__/highlightLines.spec.js.snap (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/__snapshots__/hoist.spec.js.snap (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/__snapshots__/lineNumers.spec.js.snap (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/__snapshots__/link.spec.js.snap (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/__snapshots__/snippet.spec.js.snap (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/containers.spec.js (87%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/fragments/code-highlightLines-multiple.md (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/fragments/code-highlightLines-single.md (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/fragments/code-snippet-highlightLines-multiple.md (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/fragments/code-snippet-highlightLines-single.md (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/fragments/code-snippet.md (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/fragments/code.md (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/fragments/container-danger.md (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/fragments/container-tip-override.md (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/fragments/container-tip.md (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/fragments/container-v-pre.md (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/fragments/container-warning.md (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/fragments/hoist.md (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/fragments/snippet.js (100%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/highlight.spec.js (87%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/highlightLines.spec.js (92%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/hoist.spec.js (84%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/lineNumers.spec.js (79%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/link.spec.js (94%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/slugify.spec.js (92%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/snippet.spec.js (86%) rename packages/@vuepress/{core/__test__/markdown => markdown/__tests__}/util.js (100%) rename packages/@vuepress/{core/lib/markdown => markdown/lib}/component.js (100%) rename packages/@vuepress/{core/lib/markdown => markdown/lib}/containers.js (100%) rename packages/@vuepress/{core/lib/markdown => markdown/lib}/highlight.js (91%) rename packages/@vuepress/{core/lib/markdown => markdown/lib}/highlightLines.js (100%) rename packages/@vuepress/{core/lib/markdown => markdown/lib}/hoist.js (100%) rename packages/@vuepress/{core/lib/markdown => markdown/lib}/index.js (55%) rename packages/@vuepress/{core/lib/markdown => markdown/lib}/lineNumbers.js (100%) rename packages/@vuepress/{core/lib/markdown => markdown/lib}/link.js (100%) rename packages/@vuepress/{core/lib/markdown => markdown/lib}/preWrapper.js (100%) rename packages/@vuepress/{core/lib/markdown => markdown/lib}/slugify.js (100%) rename packages/@vuepress/{core/lib/markdown => markdown/lib}/snippet.js (96%) create mode 100644 packages/@vuepress/markdown/package.json create mode 100644 packages/@vuepress/shared-utils/lib/extractHeaders.js create mode 100644 packages/@vuepress/shared-utils/lib/hash.js create mode 100644 packages/@vuepress/shared-utils/lib/inferTitle.js diff --git a/packages/@vuepress/core/lib/dev.js b/packages/@vuepress/core/lib/dev.js index 5383efb893..a55667412c 100644 --- a/packages/@vuepress/core/lib/dev.js +++ b/packages/@vuepress/core/lib/dev.js @@ -17,7 +17,7 @@ module.exports = async function dev (sourceDir, cliOptions = {}) { const DevLogPlugin = require('./webpack/DevLogPlugin') const createClientConfig = require('./webpack/createClientConfig') const { applyUserWebpackConfig } = require('./util/index') - const { frontmatterEmitter } = require('./webpack/markdownLoader') + const { frontmatterEmitter } = require('@vuepress/markdown-loader') logger.wait('\nExtracting site metadata...') const options = await prepare(sourceDir, cliOptions, false /* isProd */) diff --git a/packages/@vuepress/core/lib/prepare/AppContext.js b/packages/@vuepress/core/lib/prepare/AppContext.js index 81ccbb1fa9..6b1d945899 100644 --- a/packages/@vuepress/core/lib/prepare/AppContext.js +++ b/packages/@vuepress/core/lib/prepare/AppContext.js @@ -5,7 +5,7 @@ */ const path = require('path') -const createMarkdown = require('../markdown/index') +const createMarkdown = require('./createMarkdown') const loadConfig = require('./loadConfig') const loadTheme = require('./loadTheme') const { fs, logger, chalk, globby, sort, datatypes: { isFunction }} = require('@vuepress/shared-utils') @@ -69,7 +69,7 @@ module.exports = class AppContext { this.resolveTemplates() await this.resolveTheme() this.resolvePlugins() - this.markdown = createMarkdown(this.siteConfig.markdown, this.pluginAPI) + this.markdown = createMarkdown(this) await this.resolvePages() await Promise.all( @@ -79,7 +79,6 @@ module.exports = class AppContext { ) await this.pluginAPI.options.ready.apply() - this.pluginAPI.options.extendMarkdown.syncApply(this.markdown) await this.pluginAPI.options.clientDynamicModules.apply(this) await this.pluginAPI.options.globalUIComponents.apply(this) await this.pluginAPI.options.enhanceAppFiles.apply(this) diff --git a/packages/@vuepress/core/lib/prepare/Page.js b/packages/@vuepress/core/lib/prepare/Page.js index ed72e94256..af4cdba7f5 100644 --- a/packages/@vuepress/core/lib/prepare/Page.js +++ b/packages/@vuepress/core/lib/prepare/Page.js @@ -5,9 +5,9 @@ */ const path = require('path') -const slugify = require('../markdown/slugify') -const { inferTitle, inferDate, extractHeaders, DATE_RE } = require('../util/index') -const { fs, fileToPath, parseFrontmatter, getPermalink } = require('@vuepress/shared-utils') +const slugify = require('../../../markdown/lib/slugify') +const { inferDate, DATE_RE } = require('../util/index') +const { extractHeaders, fs, fileToPath, parseFrontmatter, getPermalink, inferTitle } = require('@vuepress/shared-utils') /** * Expose Page class. diff --git a/packages/@vuepress/core/lib/prepare/createMarkdown.js b/packages/@vuepress/core/lib/prepare/createMarkdown.js new file mode 100644 index 0000000000..6f399f66d4 --- /dev/null +++ b/packages/@vuepress/core/lib/prepare/createMarkdown.js @@ -0,0 +1,33 @@ +'use strict' + +/** + * Module dependencies. + */ + +const createMarkdown = require('@vuepress/markdown') + +/** + * Expose createMarkdown. + */ + +module.exports = function (ctx) { + const { markdown: markdownConfig = {}} = ctx.siteConfig + const { chainMarkdown, extendMarkdown } = markdownConfig + + const beforeInstantiate = config => { + chainMarkdown && chainMarkdown(config) + ctx.pluginAPI.options.chainMarkdown.syncApply(config) + } + + const afterInstantiate = md => { + extendMarkdown && extendMarkdown(md) + ctx.pluginAPI.options.extendMarkdown.syncApply(md) + } + + return createMarkdown( + Object.assign(markdownConfig, { + beforeInstantiate, + afterInstantiate + }) + ) +} diff --git a/packages/@vuepress/core/lib/util/index.js b/packages/@vuepress/core/lib/util/index.js index 04f70eaacb..20b97a5154 100644 --- a/packages/@vuepress/core/lib/util/index.js +++ b/packages/@vuepress/core/lib/util/index.js @@ -1,11 +1,5 @@ 'use strict' -/** - * Module dependencies. - */ - -const { deeplyParseHeaders } = require('@vuepress/shared-utils') - /** * Normalize head tag config. * @@ -49,65 +43,6 @@ exports.applyUserWebpackConfig = function (userConfig, config, isServer) { return config } -/** - * Infer a page's title via frontmatter and content. - * - * @param frontmatter - * @param strippedContent - * @returns {*} - */ - -exports.inferTitle = function (frontmatter, strippedContent) { - if (frontmatter.home) { - return 'Home' - } - if (frontmatter.title) { - return deeplyParseHeaders(frontmatter.title) - } - const match = strippedContent.trim().match(/^#+\s+(.*)/) - if (match) { - return deeplyParseHeaders(match[1]) - } -} - -/** - * Extract heeaders from markdown source content. - * - * @param {string} content - * @param {array} include - * @param {object} md - * @returns {array} - */ - -const LRU = require('lru-cache') -const cache = LRU({ max: 1000 }) - -exports.extractHeaders = function (content, include = [], md) { - const key = content + include.join(',') - const hit = cache.get(key) - if (hit) { - return hit - } - - const tokens = md.parse(content, {}) - - const res = [] - tokens.forEach((t, i) => { - if (t.type === 'heading_open' && include.includes(t.tag)) { - const title = tokens[i + 1].content - const slug = t.attrs.find(([name]) => name === 'id')[1] - res.push({ - level: parseInt(t.tag.slice(1), 10), - title: deeplyParseHeaders(title), - slug: slug || md.slugify(title) - }) - } - }) - - cache.set(key, res) - return res -} - /** * Infer date. * diff --git a/packages/@vuepress/core/lib/webpack/createBaseConfig.js b/packages/@vuepress/core/lib/webpack/createBaseConfig.js index c153646661..c2788ff5b6 100644 --- a/packages/@vuepress/core/lib/webpack/createBaseConfig.js +++ b/packages/@vuepress/core/lib/webpack/createBaseConfig.js @@ -136,7 +136,7 @@ module.exports = function createBaseConfig ({ mdRule .use('markdown-loader') - .loader(require.resolve('./markdownLoader')) + .loader(require.resolve('@vuepress/markdown-loader')) .options({ sourceDir, markdown }) config.module diff --git a/packages/@vuepress/core/package.json b/packages/@vuepress/core/package.json index 2d7a33bb9c..e88364f6fb 100644 --- a/packages/@vuepress/core/package.json +++ b/packages/@vuepress/core/package.json @@ -21,6 +21,8 @@ "dependencies": { "@babel/core": "7.0.0-beta.47", "@vue/babel-preset-app": "3.0.0-beta.11", + "@vuepress/markdown": "^1.0.0", + "@vuepress/markdown-loader": "^1.0.0", "@vuepress/shared-utils": "^1.0.0", "@vuepress/plugin-last-updated": "^1.0.0", "@vuepress/plugin-register-components": "^1.0.0", @@ -33,8 +35,6 @@ "copy-webpack-plugin": "^4.5.1", "cross-spawn": "^6.0.5", "css-loader": "^0.28.11", - "diacritics": "^1.3.0", - "escape-html": "^1.0.3", "file-loader": "^1.1.11", "globby": "^8.0.1", "gray-matter": "^4.0.1", @@ -43,18 +43,11 @@ "koa-mount": "^3.0.0", "koa-range": "^0.3.0", "koa-static": "^4.0.2", - "loader-utils": "^1.1.0", "lru-cache": "^4.1.2", - "markdown-it": "^8.4.1", - "markdown-it-anchor": "^5.0.2", - "markdown-it-container": "^2.0.0", - "markdown-it-emoji": "^1.4.0", - "markdown-it-table-of-contents": "^0.4.0", "mini-css-extract-plugin": "^0.4.1", "optimize-css-assets-webpack-plugin": "^4.0.0", "portfinder": "^1.0.13", "postcss-loader": "^2.1.5", - "prismjs": "^1.13.0", "toml": "^2.3.3", "url-loader": "^1.0.1", "vue": "^2.5.16", @@ -67,8 +60,7 @@ "webpack-chain": "^4.6.0", "webpack-merge": "^4.1.2", "webpack-serve": "^1.0.2", - "webpackbar": "^2.6.1", - "markdown-it-chain": "^1.2.0" + "webpackbar": "^2.6.1" }, "engines": { "node": ">=8" diff --git a/packages/@vuepress/markdown-loader/.npmignore b/packages/@vuepress/markdown-loader/.npmignore new file mode 100644 index 0000000000..18f0a334a4 --- /dev/null +++ b/packages/@vuepress/markdown-loader/.npmignore @@ -0,0 +1,2 @@ +__tests__ +__mocks__ \ No newline at end of file diff --git a/packages/@vuepress/markdown-loader/README.md b/packages/@vuepress/markdown-loader/README.md new file mode 100644 index 0000000000..90ad547ca5 --- /dev/null +++ b/packages/@vuepress/markdown-loader/README.md @@ -0,0 +1,24 @@ +# @vuepress/markdown-loader + +> markdown-loader for vuepress + +## Usage + +```js +const rule = config.module + .rule('markdown') + .test(/\.md$/) + +rule + .use('vue-loader') + .loader('vue-loader') + .options({ /* ... */ }) + +rule + .use('markdown-loader') + .loader(require.resolve('@vuepress/markdown-loader')) + .options({ + markdown: /* instance created by @vuepress/markdown */, + sourceDir: /* root source directory of your docs */, + }) +``` diff --git a/packages/@vuepress/core/lib/webpack/markdownLoader.js b/packages/@vuepress/markdown-loader/index.js similarity index 91% rename from packages/@vuepress/core/lib/webpack/markdownLoader.js rename to packages/@vuepress/markdown-loader/index.js index 1f4e4d84dd..fd35030157 100644 --- a/packages/@vuepress/core/lib/webpack/markdownLoader.js +++ b/packages/@vuepress/markdown-loader/index.js @@ -4,14 +4,12 @@ * Module dependencies. */ -const fs = require('fs') const path = require('path') -const hash = require('hash-sum') const { EventEmitter } = require('events') const { getOptions } = require('loader-utils') -const { inferTitle, extractHeaders } = require('../util/index') -const { parseFrontmatter } = require('@vuepress/shared-utils') +const { fs, hash, parseFrontmatter, inferTitle, extractHeaders } = require('@vuepress/shared-utils') const LRU = require('lru-cache') +const md = require('@vuepress/markdown') const cache = LRU({ max: 1000 }) const devCache = LRU({ max: 1000 }) @@ -23,7 +21,12 @@ const devCache = LRU({ max: 1000 }) module.exports = function (src) { const isProd = process.env.NODE_ENV === 'production' const isServer = this.target === 'node' - const { markdown, sourceDir } = getOptions(this) + const options = getOptions(this) + const { sourceDir } = options + let { markdown } = options + if (!markdown) { + markdown = md() + } // we implement a manual cache here because this loader is chained before // vue-loader, and will be applied on the same file multiple times when @@ -69,18 +72,23 @@ module.exports = function (src) { // check if relative links are valid links && links.forEach(link => { link = decodeURIComponent(link) + const shortname = link .replace(/#.*$/, '') .replace(/\.html$/, '.md') + const filename = shortname .replace(/\/$/, '/README.md') .replace(/^\//, sourceDir + '/') + const altname = shortname .replace(/\/$/, '/index.md') .replace(/^\//, sourceDir + '/') + const dir = path.dirname(this.resourcePath) const file = path.resolve(dir, filename) const altfile = altname !== filename ? path.resolve(dir, altname) : null + if (!fs.existsSync(file) && (!altfile || !fs.existsSync(altfile))) { this.emitWarning( new Error( @@ -95,7 +103,6 @@ module.exports = function (src) { `\n` + - `` + (hoistedTags || []).join('\n') ) cache.set(key, res) diff --git a/packages/@vuepress/markdown-loader/package.json b/packages/@vuepress/markdown-loader/package.json new file mode 100644 index 0000000000..7aaa5bafc8 --- /dev/null +++ b/packages/@vuepress/markdown-loader/package.json @@ -0,0 +1,29 @@ +{ + "name": "@vuepress/markdown-loader", + "version": "1.0.0", + "description": "markdown-loader for vuepress", + "main": "index.js", + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/vuejs/vuepress.git" + }, + "keywords": [ + "documentation", + "vue", + "vuepress", + "generator" + ], + "dependencies": { + "@vuepress/markdown": "1.0.0", + "loader-utils": "^1.1.0" + }, + "author": "Evan You", + "license": "MIT", + "bugs": { + "url": "https://github.com/vuejs/vuepress/issues" + }, + "homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/markdown-loader#readme" +} diff --git a/packages/@vuepress/markdown/.npmignore b/packages/@vuepress/markdown/.npmignore new file mode 100644 index 0000000000..18f0a334a4 --- /dev/null +++ b/packages/@vuepress/markdown/.npmignore @@ -0,0 +1,2 @@ +__tests__ +__mocks__ \ No newline at end of file diff --git a/packages/@vuepress/markdown/README.md b/packages/@vuepress/markdown/README.md new file mode 100644 index 0000000000..5be9b185d7 --- /dev/null +++ b/packages/@vuepress/markdown/README.md @@ -0,0 +1,3 @@ +# @vuepress/markdown + +> markdown for vuepress \ No newline at end of file diff --git a/packages/@vuepress/core/__test__/markdown/__snapshots__/containers.spec.js.snap b/packages/@vuepress/markdown/__tests__/__snapshots__/containers.spec.js.snap similarity index 100% rename from packages/@vuepress/core/__test__/markdown/__snapshots__/containers.spec.js.snap rename to packages/@vuepress/markdown/__tests__/__snapshots__/containers.spec.js.snap diff --git a/packages/@vuepress/core/__test__/markdown/__snapshots__/highlight.spec.js.snap b/packages/@vuepress/markdown/__tests__/__snapshots__/highlight.spec.js.snap similarity index 100% rename from packages/@vuepress/core/__test__/markdown/__snapshots__/highlight.spec.js.snap rename to packages/@vuepress/markdown/__tests__/__snapshots__/highlight.spec.js.snap diff --git a/packages/@vuepress/core/__test__/markdown/__snapshots__/highlightLines.spec.js.snap b/packages/@vuepress/markdown/__tests__/__snapshots__/highlightLines.spec.js.snap similarity index 100% rename from packages/@vuepress/core/__test__/markdown/__snapshots__/highlightLines.spec.js.snap rename to packages/@vuepress/markdown/__tests__/__snapshots__/highlightLines.spec.js.snap diff --git a/packages/@vuepress/core/__test__/markdown/__snapshots__/hoist.spec.js.snap b/packages/@vuepress/markdown/__tests__/__snapshots__/hoist.spec.js.snap similarity index 100% rename from packages/@vuepress/core/__test__/markdown/__snapshots__/hoist.spec.js.snap rename to packages/@vuepress/markdown/__tests__/__snapshots__/hoist.spec.js.snap diff --git a/packages/@vuepress/core/__test__/markdown/__snapshots__/lineNumers.spec.js.snap b/packages/@vuepress/markdown/__tests__/__snapshots__/lineNumers.spec.js.snap similarity index 100% rename from packages/@vuepress/core/__test__/markdown/__snapshots__/lineNumers.spec.js.snap rename to packages/@vuepress/markdown/__tests__/__snapshots__/lineNumers.spec.js.snap diff --git a/packages/@vuepress/core/__test__/markdown/__snapshots__/link.spec.js.snap b/packages/@vuepress/markdown/__tests__/__snapshots__/link.spec.js.snap similarity index 100% rename from packages/@vuepress/core/__test__/markdown/__snapshots__/link.spec.js.snap rename to packages/@vuepress/markdown/__tests__/__snapshots__/link.spec.js.snap diff --git a/packages/@vuepress/core/__test__/markdown/__snapshots__/snippet.spec.js.snap b/packages/@vuepress/markdown/__tests__/__snapshots__/snippet.spec.js.snap similarity index 100% rename from packages/@vuepress/core/__test__/markdown/__snapshots__/snippet.spec.js.snap rename to packages/@vuepress/markdown/__tests__/__snapshots__/snippet.spec.js.snap diff --git a/packages/@vuepress/core/__test__/markdown/containers.spec.js b/packages/@vuepress/markdown/__tests__/containers.spec.js similarity index 87% rename from packages/@vuepress/core/__test__/markdown/containers.spec.js rename to packages/@vuepress/markdown/__tests__/containers.spec.js index b21523811a..e2c0071a31 100644 --- a/packages/@vuepress/core/__test__/markdown/containers.spec.js +++ b/packages/@vuepress/markdown/__tests__/containers.spec.js @@ -1,5 +1,5 @@ import { Md, getFragment } from './util' -import containers from '../../lib/markdown/containers.js' +import containers from '../lib/containers.js' const mdC = Md().use(containers) diff --git a/packages/@vuepress/core/__test__/markdown/fragments/code-highlightLines-multiple.md b/packages/@vuepress/markdown/__tests__/fragments/code-highlightLines-multiple.md similarity index 100% rename from packages/@vuepress/core/__test__/markdown/fragments/code-highlightLines-multiple.md rename to packages/@vuepress/markdown/__tests__/fragments/code-highlightLines-multiple.md diff --git a/packages/@vuepress/core/__test__/markdown/fragments/code-highlightLines-single.md b/packages/@vuepress/markdown/__tests__/fragments/code-highlightLines-single.md similarity index 100% rename from packages/@vuepress/core/__test__/markdown/fragments/code-highlightLines-single.md rename to packages/@vuepress/markdown/__tests__/fragments/code-highlightLines-single.md diff --git a/packages/@vuepress/core/__test__/markdown/fragments/code-snippet-highlightLines-multiple.md b/packages/@vuepress/markdown/__tests__/fragments/code-snippet-highlightLines-multiple.md similarity index 100% rename from packages/@vuepress/core/__test__/markdown/fragments/code-snippet-highlightLines-multiple.md rename to packages/@vuepress/markdown/__tests__/fragments/code-snippet-highlightLines-multiple.md diff --git a/packages/@vuepress/core/__test__/markdown/fragments/code-snippet-highlightLines-single.md b/packages/@vuepress/markdown/__tests__/fragments/code-snippet-highlightLines-single.md similarity index 100% rename from packages/@vuepress/core/__test__/markdown/fragments/code-snippet-highlightLines-single.md rename to packages/@vuepress/markdown/__tests__/fragments/code-snippet-highlightLines-single.md diff --git a/packages/@vuepress/core/__test__/markdown/fragments/code-snippet.md b/packages/@vuepress/markdown/__tests__/fragments/code-snippet.md similarity index 100% rename from packages/@vuepress/core/__test__/markdown/fragments/code-snippet.md rename to packages/@vuepress/markdown/__tests__/fragments/code-snippet.md diff --git a/packages/@vuepress/core/__test__/markdown/fragments/code.md b/packages/@vuepress/markdown/__tests__/fragments/code.md similarity index 100% rename from packages/@vuepress/core/__test__/markdown/fragments/code.md rename to packages/@vuepress/markdown/__tests__/fragments/code.md diff --git a/packages/@vuepress/core/__test__/markdown/fragments/container-danger.md b/packages/@vuepress/markdown/__tests__/fragments/container-danger.md similarity index 100% rename from packages/@vuepress/core/__test__/markdown/fragments/container-danger.md rename to packages/@vuepress/markdown/__tests__/fragments/container-danger.md diff --git a/packages/@vuepress/core/__test__/markdown/fragments/container-tip-override.md b/packages/@vuepress/markdown/__tests__/fragments/container-tip-override.md similarity index 100% rename from packages/@vuepress/core/__test__/markdown/fragments/container-tip-override.md rename to packages/@vuepress/markdown/__tests__/fragments/container-tip-override.md diff --git a/packages/@vuepress/core/__test__/markdown/fragments/container-tip.md b/packages/@vuepress/markdown/__tests__/fragments/container-tip.md similarity index 100% rename from packages/@vuepress/core/__test__/markdown/fragments/container-tip.md rename to packages/@vuepress/markdown/__tests__/fragments/container-tip.md diff --git a/packages/@vuepress/core/__test__/markdown/fragments/container-v-pre.md b/packages/@vuepress/markdown/__tests__/fragments/container-v-pre.md similarity index 100% rename from packages/@vuepress/core/__test__/markdown/fragments/container-v-pre.md rename to packages/@vuepress/markdown/__tests__/fragments/container-v-pre.md diff --git a/packages/@vuepress/core/__test__/markdown/fragments/container-warning.md b/packages/@vuepress/markdown/__tests__/fragments/container-warning.md similarity index 100% rename from packages/@vuepress/core/__test__/markdown/fragments/container-warning.md rename to packages/@vuepress/markdown/__tests__/fragments/container-warning.md diff --git a/packages/@vuepress/core/__test__/markdown/fragments/hoist.md b/packages/@vuepress/markdown/__tests__/fragments/hoist.md similarity index 100% rename from packages/@vuepress/core/__test__/markdown/fragments/hoist.md rename to packages/@vuepress/markdown/__tests__/fragments/hoist.md diff --git a/packages/@vuepress/core/__test__/markdown/fragments/snippet.js b/packages/@vuepress/markdown/__tests__/fragments/snippet.js similarity index 100% rename from packages/@vuepress/core/__test__/markdown/fragments/snippet.js rename to packages/@vuepress/markdown/__tests__/fragments/snippet.js diff --git a/packages/@vuepress/core/__test__/markdown/highlight.spec.js b/packages/@vuepress/markdown/__tests__/highlight.spec.js similarity index 87% rename from packages/@vuepress/core/__test__/markdown/highlight.spec.js rename to packages/@vuepress/markdown/__tests__/highlight.spec.js index 6870dcc370..0ca9cb3cd3 100644 --- a/packages/@vuepress/core/__test__/markdown/highlight.spec.js +++ b/packages/@vuepress/markdown/__tests__/highlight.spec.js @@ -1,5 +1,5 @@ import { Md, getFragment } from './util' -import highlight from '../../lib/markdown/highlight.js' +import highlight from '../lib/highlight.js' const md = Md() const mdH = Md().set({ highlight }) diff --git a/packages/@vuepress/core/__test__/markdown/highlightLines.spec.js b/packages/@vuepress/markdown/__tests__/highlightLines.spec.js similarity index 92% rename from packages/@vuepress/core/__test__/markdown/highlightLines.spec.js rename to packages/@vuepress/markdown/__tests__/highlightLines.spec.js index 06f1394b7c..d242c9a4bb 100644 --- a/packages/@vuepress/core/__test__/markdown/highlightLines.spec.js +++ b/packages/@vuepress/markdown/__tests__/highlightLines.spec.js @@ -1,5 +1,5 @@ import { Md, getFragment } from './util' -import highlightLines from '../../lib/markdown/highlightLines.js' +import highlightLines from '../lib/highlightLines.js' const md = Md() const mdH = Md().use(highlightLines) diff --git a/packages/@vuepress/core/__test__/markdown/hoist.spec.js b/packages/@vuepress/markdown/__tests__/hoist.spec.js similarity index 84% rename from packages/@vuepress/core/__test__/markdown/hoist.spec.js rename to packages/@vuepress/markdown/__tests__/hoist.spec.js index a625a39c29..ae89a6f452 100644 --- a/packages/@vuepress/core/__test__/markdown/hoist.spec.js +++ b/packages/@vuepress/markdown/__tests__/hoist.spec.js @@ -1,6 +1,6 @@ import { Md, getFragment } from './util' -import hoist from '../../lib/markdown/hoist.js' -import { dataReturnable } from '../../lib/markdown/index.js' +import hoist from '../lib/hoist.js' +import { dataReturnable } from '../lib/index.js' const md = Md().set({ html: true }) const mdH = Md().set({ html: true }).use(hoist) diff --git a/packages/@vuepress/core/__test__/markdown/lineNumers.spec.js b/packages/@vuepress/markdown/__tests__/lineNumers.spec.js similarity index 79% rename from packages/@vuepress/core/__test__/markdown/lineNumers.spec.js rename to packages/@vuepress/markdown/__tests__/lineNumers.spec.js index 8f3510659b..0f3f013525 100644 --- a/packages/@vuepress/core/__test__/markdown/lineNumers.spec.js +++ b/packages/@vuepress/markdown/__tests__/lineNumers.spec.js @@ -1,7 +1,7 @@ import { Md, getFragment } from './util' -import preWrapper from '../../lib/markdown/preWrapper.js' -import lineNumbers from '../../lib/markdown/lineNumbers.js' -import highlightLines from '../../lib/markdown/highlightLines.js' +import preWrapper from '../lib/preWrapper.js' +import lineNumbers from '../lib/lineNumbers.js' +import highlightLines from '../lib/highlightLines.js' // lineNumbers must be chained after preWrapper. // since lineNumbers needs to add extra stateful class to its block wrapper. diff --git a/packages/@vuepress/core/__test__/markdown/link.spec.js b/packages/@vuepress/markdown/__tests__/link.spec.js similarity index 94% rename from packages/@vuepress/core/__test__/markdown/link.spec.js rename to packages/@vuepress/markdown/__tests__/link.spec.js index 78274b6f3f..87f56f1029 100644 --- a/packages/@vuepress/core/__test__/markdown/link.spec.js +++ b/packages/@vuepress/markdown/__tests__/link.spec.js @@ -1,6 +1,6 @@ import { Md } from './util' -import link from '../../lib/markdown/link.js' -import { dataReturnable } from '../../lib/markdown/index.js' +import link from '../lib/link.js' +import { dataReturnable } from '../lib/index.js' const mdL = Md().use(link, { target: '_blank', diff --git a/packages/@vuepress/core/__test__/markdown/slugify.spec.js b/packages/@vuepress/markdown/__tests__/slugify.spec.js similarity index 92% rename from packages/@vuepress/core/__test__/markdown/slugify.spec.js rename to packages/@vuepress/markdown/__tests__/slugify.spec.js index 3247e590e3..2c6a77b6c5 100644 --- a/packages/@vuepress/core/__test__/markdown/slugify.spec.js +++ b/packages/@vuepress/markdown/__tests__/slugify.spec.js @@ -1,6 +1,6 @@ import { Md } from './util' import anchor from 'markdown-it-anchor' -import slugify from '../../lib/markdown/slugify.js' +import slugify from '../lib/slugify.js' const mdS = Md().use(anchor, { slugify, diff --git a/packages/@vuepress/core/__test__/markdown/snippet.spec.js b/packages/@vuepress/markdown/__tests__/snippet.spec.js similarity index 86% rename from packages/@vuepress/core/__test__/markdown/snippet.spec.js rename to packages/@vuepress/markdown/__tests__/snippet.spec.js index 140b68cd64..5e05b481ed 100644 --- a/packages/@vuepress/core/__test__/markdown/snippet.spec.js +++ b/packages/@vuepress/markdown/__tests__/snippet.spec.js @@ -1,6 +1,6 @@ import { Md, getFragment } from './util' -import snippet from '../../lib/markdown/snippet.js' -import highlightLines from '../../lib/markdown/highlightLines.js' +import snippet from '../lib/snippet.js' +import highlightLines from '../lib/highlightLines.js' const md = Md().use(snippet) const mdH = Md().use(snippet).use(highlightLines) diff --git a/packages/@vuepress/core/__test__/markdown/util.js b/packages/@vuepress/markdown/__tests__/util.js similarity index 100% rename from packages/@vuepress/core/__test__/markdown/util.js rename to packages/@vuepress/markdown/__tests__/util.js diff --git a/packages/@vuepress/core/lib/markdown/component.js b/packages/@vuepress/markdown/lib/component.js similarity index 100% rename from packages/@vuepress/core/lib/markdown/component.js rename to packages/@vuepress/markdown/lib/component.js diff --git a/packages/@vuepress/core/lib/markdown/containers.js b/packages/@vuepress/markdown/lib/containers.js similarity index 100% rename from packages/@vuepress/core/lib/markdown/containers.js rename to packages/@vuepress/markdown/lib/containers.js diff --git a/packages/@vuepress/core/lib/markdown/highlight.js b/packages/@vuepress/markdown/lib/highlight.js similarity index 91% rename from packages/@vuepress/core/lib/markdown/highlight.js rename to packages/@vuepress/markdown/lib/highlight.js index 39a019ba94..dbb6437206 100644 --- a/packages/@vuepress/core/lib/markdown/highlight.js +++ b/packages/@vuepress/markdown/lib/highlight.js @@ -1,7 +1,6 @@ const prism = require('prismjs') const loadLanguages = require('prismjs/components/index') -const escapeHtml = require('escape-html') -const { logger, chalk } = require('@vuepress/shared-utils') +const { logger, chalk, escapeHtml } = require('@vuepress/shared-utils') // required to make embedded highlighting work... loadLanguages(['markup', 'css', 'javascript']) diff --git a/packages/@vuepress/core/lib/markdown/highlightLines.js b/packages/@vuepress/markdown/lib/highlightLines.js similarity index 100% rename from packages/@vuepress/core/lib/markdown/highlightLines.js rename to packages/@vuepress/markdown/lib/highlightLines.js diff --git a/packages/@vuepress/core/lib/markdown/hoist.js b/packages/@vuepress/markdown/lib/hoist.js similarity index 100% rename from packages/@vuepress/core/lib/markdown/hoist.js rename to packages/@vuepress/markdown/lib/hoist.js diff --git a/packages/@vuepress/core/lib/markdown/index.js b/packages/@vuepress/markdown/lib/index.js similarity index 55% rename from packages/@vuepress/core/lib/markdown/index.js rename to packages/@vuepress/markdown/lib/index.js index 9b7e85e4f0..728aacbe9c 100644 --- a/packages/@vuepress/core/lib/markdown/index.js +++ b/packages/@vuepress/markdown/lib/index.js @@ -6,17 +6,17 @@ const Config = require('markdown-it-chain') const highlight = require('./highlight') -const highlightLines = require('./highlightLines') -const preWrapper = require('./preWrapper') -const lineNumbers = require('./lineNumbers') -const component = require('./component') -const hoistScriptStyle = require('./hoist') -const convertRouterLink = require('./link') -const containers = require('./containers') -const snippet = require('./snippet') -const emoji = require('markdown-it-emoji') -const anchor = require('markdown-it-anchor') -const toc = require('markdown-it-table-of-contents') +const highlightLinesPlugin = require('./highlightLines') +const preWrapperPlugin = require('./preWrapper') +const lineNumbersPlugin = require('./lineNumbers') +const componentPlugin = require('./component') +const hoistScriptStylePlugin = require('./hoist') +const convertRouterLinkPlugin = require('./link') +const containersPlugin = require('./containers') +const snippetPlugin = require('./snippet') +const emojiPlugin = require('markdown-it-emoji') +const anchorPlugin = require('markdown-it-anchor') +const tocPlugin = require('markdown-it-table-of-contents') const _slugify = require('./slugify') const { parseHeaders } = require('@vuepress/shared-utils') @@ -24,9 +24,18 @@ const { parseHeaders } = require('@vuepress/shared-utils') * Create markdown by config. */ -module.exports = (markdown = {}, pluginAPI) => { +module.exports = ({ + slugify, + externalLinks, + anchor, + toc, + lineNumbers, + beforeInstantiate, + afterInstantiate +} = {}) => { // allow user config slugify - const slugify = markdown.slugify || _slugify + slugify = slugify || _slugify + // using chainedAPI const config = new Config() @@ -37,75 +46,68 @@ module.exports = (markdown = {}, pluginAPI) => { .end() .plugin('component') - .use(component) + .use(componentPlugin) .end() .plugin('highlight-lines') - .use(highlightLines) + .use(highlightLinesPlugin) .end() .plugin('pre-wrapper') - .use(preWrapper) + .use(preWrapperPlugin) .end() .plugin('snippet') - .use(snippet) + .use(snippetPlugin) .end() .plugin('convert-router-link') - .use(convertRouterLink, [Object.assign({ + .use(convertRouterLinkPlugin, [Object.assign({ target: '_blank', rel: 'noopener noreferrer' - }, markdown.externalLinks)]) + }, externalLinks)]) .end() .plugin('hoist-script-style') - .use(hoistScriptStyle) + .use(hoistScriptStylePlugin) .end() .plugin('containers') - .use(containers) + .use(containersPlugin) .end() .plugin('emoji') - .use(emoji) + .use(emojiPlugin) .end() .plugin('anchor') - .use(anchor, [Object.assign({ + .use(anchorPlugin, [Object.assign({ slugify, permalink: true, permalinkBefore: true, permalinkSymbol: '#' - }, markdown.anchor)]) + }, anchor)]) .end() .plugin('toc') - .use(toc, [Object.assign({ + .use(tocPlugin, [Object.assign({ slugify, includeLevel: [2, 3], format: parseHeaders - }, markdown.toc)]) + }, toc)]) .end() - if (markdown.lineNumbers) { + if (lineNumbers) { config .plugin('line-numbers') - .use(lineNumbers) + .use(lineNumbersPlugin) } - pluginAPI.options.chainMarkdown.syncApply(config) - - if (markdown.chainMarkdown) { - markdown.chainMarkdown(config) - } + beforeInstantiate && beforeInstantiate(config) const md = config.toMd() - // apply user config - if (markdown.config) { - markdown.config(md) - } + afterInstantiate && afterInstantiate(md) module.exports.dataReturnable(md) diff --git a/packages/@vuepress/core/lib/markdown/lineNumbers.js b/packages/@vuepress/markdown/lib/lineNumbers.js similarity index 100% rename from packages/@vuepress/core/lib/markdown/lineNumbers.js rename to packages/@vuepress/markdown/lib/lineNumbers.js diff --git a/packages/@vuepress/core/lib/markdown/link.js b/packages/@vuepress/markdown/lib/link.js similarity index 100% rename from packages/@vuepress/core/lib/markdown/link.js rename to packages/@vuepress/markdown/lib/link.js diff --git a/packages/@vuepress/core/lib/markdown/preWrapper.js b/packages/@vuepress/markdown/lib/preWrapper.js similarity index 100% rename from packages/@vuepress/core/lib/markdown/preWrapper.js rename to packages/@vuepress/markdown/lib/preWrapper.js diff --git a/packages/@vuepress/core/lib/markdown/slugify.js b/packages/@vuepress/markdown/lib/slugify.js similarity index 100% rename from packages/@vuepress/core/lib/markdown/slugify.js rename to packages/@vuepress/markdown/lib/slugify.js diff --git a/packages/@vuepress/core/lib/markdown/snippet.js b/packages/@vuepress/markdown/lib/snippet.js similarity index 96% rename from packages/@vuepress/core/lib/markdown/snippet.js rename to packages/@vuepress/markdown/lib/snippet.js index a677e12f77..834ff496a1 100644 --- a/packages/@vuepress/core/lib/markdown/snippet.js +++ b/packages/@vuepress/markdown/lib/snippet.js @@ -1,4 +1,4 @@ -const fs = require('fs') +const { fs } = require('@vuepress/shared-utils') module.exports = function snippet (md, options = {}) { const root = options.root || process.cwd() diff --git a/packages/@vuepress/markdown/package.json b/packages/@vuepress/markdown/package.json new file mode 100644 index 0000000000..5e9ff0d41c --- /dev/null +++ b/packages/@vuepress/markdown/package.json @@ -0,0 +1,37 @@ +{ + "name": "@vuepress/markdown", + "version": "1.0.0", + "description": "markdown for vuepress", + "main": "lib/index.js", + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/vuejs/vuepress.git" + }, + "keywords": [ + "documentation", + "vue", + "vuepress", + "generator", + "markdown" + ], + "dependencies": { + "@vuepress/shared-utils": "^1.0.0", + "markdown-it": "^8.4.1", + "markdown-it-anchor": "^5.0.2", + "markdown-it-container": "^2.0.0", + "markdown-it-emoji": "^1.4.0", + "markdown-it-table-of-contents": "^0.4.0", + "markdown-it-chain": "^1.2.0", + "prismjs": "^1.13.0", + "diacritics": "^1.3.0" + }, + "author": "Evan You", + "license": "MIT", + "bugs": { + "url": "https://github.com/vuejs/vuepress/issues" + }, + "homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/markdown#readme" +} diff --git a/packages/@vuepress/shared-utils/index.js b/packages/@vuepress/shared-utils/index.js index a1a49bd434..4b1b37c9ca 100644 --- a/packages/@vuepress/shared-utils/index.js +++ b/packages/@vuepress/shared-utils/index.js @@ -4,17 +4,27 @@ exports.codegen = require('./lib/codegen') exports.compose = require('./lib/compose') exports.datatypes = require('./lib/datatypes') exports.parseFrontmatter = require('./lib/parseFrontmatter') + exports.unescapeHtml = require('./lib/unescapeHtml') +exports.escapeHtml = require('escape-html') + exports.parseEmojis = require('./lib/parseEmojis') exports.parseHeaders = require('./lib/parseHeaders') exports.deeplyParseHeaders = require('./lib/deeplyParseHeaders') exports.fileToPath = require('./lib/fileToPath') exports.sort = require('./lib/sort') + exports.ensureLeadingSlash = require('./lib/ensureLeadingSlash') exports.ensureEndingSlash = require('./lib/ensureEndingSlash') + exports.getPermalink = require('./lib/getPermalink') exports.shortcutPackageResolver = require('./lib/shortcutPackageResolver') +exports.inferTitle = require('./lib/inferTitle') + +exports.extractHeaders = require('./lib/extractHeaders') exports.chalk = require('chalk') exports.fs = require('fs-extra') exports.globby = require('globby') + +exports.hash = require('hash-sum') diff --git a/packages/@vuepress/shared-utils/lib/extractHeaders.js b/packages/@vuepress/shared-utils/lib/extractHeaders.js new file mode 100644 index 0000000000..c2fb484a79 --- /dev/null +++ b/packages/@vuepress/shared-utils/lib/extractHeaders.js @@ -0,0 +1,39 @@ +const deeplyParseHeaders = require('./deeplyParseHeaders') + +/** + * Extract heeaders from markdown source content. + * + * @param {string} content + * @param {array} include + * @param {object} md + * @returns {array} + */ + +const LRU = require('lru-cache') +const cache = LRU({ max: 1000 }) + +module.exports = function (content, include = [], md) { + const key = content + include.join(',') + const hit = cache.get(key) + if (hit) { + return hit + } + + const tokens = md.parse(content, {}) + + const res = [] + tokens.forEach((t, i) => { + if (t.type === 'heading_open' && include.includes(t.tag)) { + const title = tokens[i + 1].content + const slug = t.attrs.find(([name]) => name === 'id')[1] + res.push({ + level: parseInt(t.tag.slice(1), 10), + title: deeplyParseHeaders(title), + slug: slug || md.slugify(title) + }) + } + }) + + cache.set(key, res) + return res +} diff --git a/packages/@vuepress/shared-utils/lib/hash.js b/packages/@vuepress/shared-utils/lib/hash.js new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/packages/@vuepress/shared-utils/lib/hash.js @@ -0,0 +1 @@ + diff --git a/packages/@vuepress/shared-utils/lib/inferTitle.js b/packages/@vuepress/shared-utils/lib/inferTitle.js new file mode 100644 index 0000000000..d71243979a --- /dev/null +++ b/packages/@vuepress/shared-utils/lib/inferTitle.js @@ -0,0 +1,22 @@ +const deeplyParseHeaders = require('./deeplyParseHeaders') + +/** + * Infer a page's title via frontmatter and content. + * + * @param {object} frontmatter + * @param {string} strippedContent + * @returns {*} + */ + +module.exports = function (frontmatter, strippedContent) { + if (frontmatter.home) { + return 'Home' + } + if (frontmatter.title) { + return deeplyParseHeaders(frontmatter.title) + } + const match = strippedContent.trim().match(/^#+\s+(.*)/) + if (match) { + return deeplyParseHeaders(match[1]) + } +} diff --git a/packages/@vuepress/shared-utils/package.json b/packages/@vuepress/shared-utils/package.json index 598b11367f..4110a451e9 100644 --- a/packages/@vuepress/shared-utils/package.json +++ b/packages/@vuepress/shared-utils/package.json @@ -19,7 +19,9 @@ "dependencies": { "chalk": "^2.3.2", "fs-extra": "^5.0.0", - "globby": "^8.0.1" + "globby": "^8.0.1", + "escape-html": "^1.0.3", + "hash-sum": "^1.0.2" }, "author": "Evan You", "license": "MIT", @@ -27,4 +29,4 @@ "url": "https://github.com/vuejs/vuepress/issues" }, "homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/shared-utils#readme" -} \ No newline at end of file +}