Skip to content

Commit 918a771

Browse files
committed
fix(gitbook-treeview): calculate headers' level
1 parent 0be0335 commit 918a771

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const pageTreeview = module.exports = {
148148

149149
let minLevel = 6;
150150

151-
const _calcLevel = str => str.split('').filter(ch => ch === '#').length;
151+
const _calcLevel = str => (/^#+/.exec(str) || [''])[0].length;
152152
const headers = [].concat(content.match(/^(#)+(\s)*(.*)\n/g))
153153
.concat(content.match(/\n(#)+(\s)*(.*)/g))
154154
.map(x => {

0 commit comments

Comments
 (0)