aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorolOwOlo <26087907+olOwOlo@users.noreply.github.com>2017-11-01 22:55:58 +0800
committerolOwOlo <26087907+olOwOlo@users.noreply.github.com>2017-11-01 22:55:58 +0800
commitc01c9cffb711cf3c647e68fdb417a505aa44c784 (patch)
tree453b8a4ff59e8a5ec8b3d29a9e347331a52b905d /src
parent8cd3af63317fda36bd9ba6c4c128e0c17c4dbb39 (diff)
feat: remove excess `ul` when the title is not starting from `h1`
release 2.6.5
Diffstat (limited to 'src')
-rw-r--r--src/js/even.js12
-rw-r--r--src/package.json2
2 files changed, 13 insertions, 1 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'
diff --git a/src/package.json b/src/package.json
index 2bb8e88..1be0cce 100644
--- a/src/package.json
+++ b/src/package.json
@@ -1,6 +1,6 @@
{
"name": "even-src",
- "version": "2.6.4",
+ "version": "2.6.5",
"description": "even source file",
"main": "index.js",
"scripts": {