summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorSheogorath2018-11-19 18:29:50 +0100
committerSheogorath2018-11-19 20:20:56 +0100
commitd6dd33620c7bea3720361d51ab04668a0c913cce (patch)
treef6ee47043216417b8aa21c234e7bc5b18dd8ea6c /public
parent9951b7df7c6523838b413700d51930956c467d6a (diff)
Fix wrong anchors
While experimenting with the ToC changes, it became obvious that anchors for those unnamed headers don't work. This patch fixes those links by running the autolinkify twice and make sure linkify only adds links to non-empty ids. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
Diffstat (limited to 'public')
-rw-r--r--public/js/extra.js6
-rw-r--r--public/js/index.js1
2 files changed, 5 insertions, 2 deletions
diff --git a/public/js/extra.js b/public/js/extra.js
index ed1470be..76e95635 100644
--- a/public/js/extra.js
+++ b/public/js/extra.js
@@ -846,11 +846,13 @@ const linkifyAnchors = (level, containingElement) => {
let header = headers[i]
if (header.getElementsByClassName('anchor').length === 0) {
if (typeof header.id === 'undefined' || header.id === '') {
- // to escape characters not allow in css and humanize
+ // to escape characters not allow in css and humanize
const id = slugifyWithUTF8(getHeaderContent(header))
header.id = id
}
- header.insertBefore(anchorForId(header.id), header.firstChild)
+ if (!(typeof header.id === 'undefined' || header.id === '')) {
+ header.insertBefore(anchorForId(header.id), header.firstChild)
+ }
}
}
}
diff --git a/public/js/index.js b/public/js/index.js
index 98c3b6d2..a7f4df94 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -2786,6 +2786,7 @@ function updateViewInner () {
renderTOC(ui.area.markdown)
generateToc('ui-toc')
generateToc('ui-toc-affix')
+ autoLinkify(ui.area.markdown)
generateScrollspy()
updateScrollspy()
smoothHashScroll()