Skip to content

Commit

Permalink
feat($markdown): pass rest options to instantiate markdown-it
Browse files Browse the repository at this point in the history
Close: #1040

e.g.

  markdown: {
    config: md => {
      md.set({linkify: true});
    }
  }

shortcut:

  markdown: {
    linkify: true
  },
  • Loading branch information
ulivz committed Nov 29, 2018
1 parent 8dd418e commit d8db81c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
23 changes: 12 additions & 11 deletions packages/@vuepress/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -110,7 +111,7 @@ module.exports = ({

beforeInstantiate && beforeInstantiate(config)

const md = config.toMd()
const md = config.toMd(require('markdown-it'), markdown)

afterInstantiate && afterInstantiate(md)

Expand Down
2 changes: 1 addition & 1 deletion packages/@vuepress/markdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit d8db81c

Please sign in to comment.