From f8d118bdb3aa7bf9998c9609a49e6110c049d5c5 Mon Sep 17 00:00:00 2001 From: Xinyu Liu Date: Fri, 11 May 2018 23:45:20 +0800 Subject: [PATCH 1/2] fix: emoji work with toc --- lib/markdown/index.js | 4 +++- lib/util/index.js | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/markdown/index.js b/lib/markdown/index.js index e945e550df..2c3499d1e1 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: header => parseHeaders(header) }, 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] From 7fc032039df6d2b6553dd0be0119c3fd960ad5de Mon Sep 17 00:00:00 2001 From: ULIVZ <472590061@qq.com> Date: Sat, 12 May 2018 15:40:22 +0800 Subject: [PATCH 2/2] chore: tweaks --- lib/markdown/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/markdown/index.js b/lib/markdown/index.js index 2c3499d1e1..82b43e6d76 100644 --- a/lib/markdown/index.js +++ b/lib/markdown/index.js @@ -39,7 +39,7 @@ module.exports = ({ markdown = {}} = {}) => { .use(toc, Object.assign({ slugify, includeLevel: [2, 3], - format: header => parseHeaders(header) + format: parseHeaders }, markdown.toc)) // apply user config