From d8db81c01d6bc61fe35e1b23a28f52327a7b0313 Mon Sep 17 00:00:00 2001 From: ULIVZ <472590061@qq.com> Date: Fri, 30 Nov 2018 00:12:41 +0800 Subject: [PATCH] feat($markdown): pass rest options to instantiate markdown-it Close: #1040 e.g. markdown: { config: md => { md.set({linkify: true}); } } shortcut: markdown: { linkify: true }, --- packages/@vuepress/markdown/index.js | 23 ++++++++++++----------- packages/@vuepress/markdown/package.json | 2 +- yarn.lock | 6 +++--- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/packages/@vuepress/markdown/index.js b/packages/@vuepress/markdown/index.js index e5a411b459..896f22d79c 100644 --- a/packages/@vuepress/markdown/index.js +++ b/packages/@vuepress/markdown/index.js @@ -25,17 +25,18 @@ const { parseHeaders, slugify: _slugify, logger, chalk } = require('@vuepress/sh * Create markdown by config. */ -module.exports = ({ - slugify, - externalLinks, - anchor, - toc, - lineNumbers, - beforeInstantiate, - afterInstantiate -} = {}) => { +module.exports = (markdown = {}) => { + const { + externalLinks, + anchor, + toc, + lineNumbers, + beforeInstantiate, + afterInstantiate + } = markdown + // allow user config slugify - slugify = slugify || _slugify + const slugify = markdown.slugify || _slugify // using chainedAPI const config = new Config() @@ -110,7 +111,7 @@ module.exports = ({ beforeInstantiate && beforeInstantiate(config) - const md = config.toMd() + const md = config.toMd(require('markdown-it'), markdown) afterInstantiate && afterInstantiate(md) diff --git a/packages/@vuepress/markdown/package.json b/packages/@vuepress/markdown/package.json index d417794d09..c27cf454e1 100644 --- a/packages/@vuepress/markdown/package.json +++ b/packages/@vuepress/markdown/package.json @@ -21,7 +21,7 @@ "@vuepress/shared-utils": "^1.0.0-alpha.24", "markdown-it": "^8.4.1", "markdown-it-anchor": "^5.0.2", - "markdown-it-chain": "^1.2.1", + "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", diff --git a/yarn.lock b/yarn.lock index d0a30abddd..4e0e253b99 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5556,9 +5556,9 @@ markdown-it-anchor@^5.0.2: version "5.0.2" resolved "https://registry.yarnpkg.com/markdown-it-anchor/-/markdown-it-anchor-5.0.2.tgz#cdd917a05b7bf92fb736a6dae3385c6d0d0fa552" -markdown-it-chain@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/markdown-it-chain/-/markdown-it-chain-1.2.1.tgz#eb77a8dc06265d48d0b6c729170e391902db22cb" +markdown-it-chain@^1.3.0: + version "1.3.0" + resolved "http://registry.npm.taobao.org/markdown-it-chain/download/markdown-it-chain-1.3.0.tgz#ccf6fe86c10266bafb4e547380dfd7f277cc17bc" dependencies: webpack-chain "^4.9.0"