Skip to content

Commit 78f5564

Browse files
alexcambosetimaschew
authored andcommitted
Updated to remove all headers under it
1 parent 6cc069c commit 78f5564

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/core/render/compiler.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,15 @@ export class Compiler {
337337
html = this.compile(text)
338338
} else {
339339
for (let i = 0; i < toc.length; i++) {
340-
toc[i].ignoreSubHeading && toc.splice(i, 1) && i--
340+
if (toc[i].ignoreSubHeading) {
341+
const deletedHeaderLevel = toc[i].level
342+
toc.splice(i, 1)
343+
// Remove headers who are under current header
344+
for (let j = i; deletedHeaderLevel < toc[j].level && j < toc.length; j++) {
345+
toc.splice(j, 1) && j-- && i++
346+
}
347+
i--
348+
}
341349
}
342350
const tree = this.cacheTree[currentPath] || genTree(toc, level)
343351
html = treeTpl(tree, '<ul>{inner}</ul>')

0 commit comments

Comments
 (0)