diff --git a/lib/markdown/index.js b/lib/markdown/index.js index e945e550df..82b43e6d76 100644 --- a/lib/markdown/index.js +++ b/lib/markdown/index.js @@ -8,6 +8,7 @@ const emoji = require('markdown-it-emoji') const anchor = require('markdown-it-anchor') const toc = require('markdown-it-table-of-contents') const _slugify = require('./slugify') +const { parseHeaders } = require('../util') module.exports = ({ markdown = {}} = {}) => { // allow user config slugify @@ -37,7 +38,8 @@ module.exports = ({ markdown = {}} = {}) => { }, markdown.anchor)) .use(toc, Object.assign({ slugify, - includeLevel: [2, 3] + includeLevel: [2, 3], + format: parseHeaders }, markdown.toc)) // apply user config diff --git a/lib/util/index.js b/lib/util/index.js index 4ef2345ad9..b9266dc85e 100644 --- a/lib/util/index.js +++ b/lib/util/index.js @@ -1,6 +1,8 @@ const spawn = require('cross-spawn') const parseHeaders = require('./parseHeaders') +exports.parseHeaders = parseHeaders + exports.normalizeHeadTag = tag => { if (typeof tag === 'string') { tag = [tag]