diff options
Diffstat (limited to 'src/js/even.js')
-rw-r--r-- | src/js/even.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/js/even.js b/src/js/even.js index 783698a..974346e 100644 --- a/src/js/even.js +++ b/src/js/even.js @@ -160,12 +160,24 @@ Even.toc = function () { // toc = true, but there are no headings tocContainer.parentNode.removeChild(tocContainer) } else { + this._refactorToc(toc) this._linkToc() this._initToc() } } } +Even._refactorToc = function (toc) { + const oldTocList = toc.children[0] + let newTocList = oldTocList + let temp + while (newTocList.children.length === 1 && (temp = newTocList.children[0].children[0]).tagName === 'UL') + newTocList = temp + + if (newTocList !== oldTocList) + toc.replaceChild(newTocList, oldTocList) +} + Even._linkToc = function () { const links = document.querySelectorAll('#TableOfContents a') for (let i = 0; i < links.length; i++) links[i].className += ' toc-link' |