diff options
author | hoijui | 2019-10-29 13:20:18 +0100 |
---|---|---|
committer | hoijui | 2019-10-30 17:46:54 +0100 |
commit | ad1a2fb19c842ea5e4cb46a24989ce95b2041902 (patch) | |
tree | bff19144acb27c663941bdce3dfc93c9509381b6 | |
parent | 3233a448c6cd7f4636daf4008fe8b98d288219d0 (diff) |
make standard conform [fix]
Signed-off-by: hoijui <hoijui.quaero@gmail.com>
Diffstat (limited to '')
-rw-r--r-- | public/js/extra.js | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/public/js/extra.js b/public/js/extra.js index 23944a17..6cda6171 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -826,7 +826,6 @@ const anchorForId = id => { } const createHeaderId = (headerContent, headerIds = null) => { - // to escape characters not allow in css and humanize const slug = slugifyWithUTF8(headerContent) let id @@ -839,13 +838,13 @@ const createHeaderId = (headerContent, headerIds = null) => { // see GitHub implementation reference: // https://gist.github.com/asabaylus/3071099#gistcomment-1593627 // it works like 'lower-case', but ... - const id_base = slug.toLowerCase() - id = id_base + const idBase = slug.toLowerCase() + id = idBase if (headerIds !== null) { // ... making sure the id is unique let i = 1 while (headerIds.has(id)) { - id = id_base + '-' + i + id = idBase + '-' + i i++ } headerIds.add(id) @@ -890,7 +889,6 @@ function getHeaderContent (header) { } function changeHeaderId ($header, id, newId) { - $header.attr('id', newId) const $headerLink = $header.find(`> a.anchor[href="#${id}"]`) $headerLink.attr('href', `#${newId}`) @@ -898,11 +896,10 @@ function changeHeaderId ($header, id, newId) { } export function deduplicatedHeaderId (view) { - // headers contained in the last change const headers = view.find(':header.raw').removeClass('raw').toArray() - if (headers.length == 0) { - return; + if (headers.length === 0) { + return } if (window.linkifyHeaderStyle === 'gfm') { // consistent with GitHub, GitLab, Pandoc & co. |