diff options
Diffstat (limited to 'web_src')
-rw-r--r-- | web_src/js/index.js | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js index 8600acc95c..395a01f059 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -2472,21 +2472,10 @@ $(document).ready(() => { // Set anchor. $('.markdown').each(function () { - const headers = {}; $(this).find('h1, h2, h3, h4, h5, h6').each(function () { let node = $(this); - const val = encodeURIComponent(node.text().toLowerCase().replace(/[^\u00C0-\u1FFF\u2C00-\uD7FF\w\- ]/g, '').replace(/[ ]/g, '-')); - let name = val; - if (headers[val] > 0) { - name = `${val}-${headers[val]}`; - } - if (headers[val] === undefined) { - headers[val] = 1; - } else { - headers[val] += 1; - } - node = node.wrap(`<div id="${name}" class="anchor-wrap" ></div>`); - node.append(`<a class="anchor" href="#${name}"><span class="octicon octicon-link"></span></a>`); + node = node.wrap('<div class="anchor-wrap"></div>'); + node.append(`<a class="anchor" href="#${encodeURIComponent(node.attr('id'))}"><span class="octicon octicon-link"></span></a>`); }); }); |