Styling the TOC

This commit is contained in:
danpros 2024-02-21 18:52:21 +07:00
commit 8da38da937
10 changed files with 371 additions and 9 deletions

View file

@ -32,12 +32,6 @@ function htmlTableOfContents (documentRef) {
headings.forEach(function (heading, index) {
heading.setAttribute('id', 'toc-' + heading.textContent.replace(/\s+/g, '-').toLowerCase());
var anchor = documentRef.createElement('a');
anchor.setAttribute('href', '#toc-' + heading.textContent.replace(/\s+/g, '-').toLowerCase());
anchor.setAttribute('class', 'anchor');
anchor.setAttribute('aria-hidden', 'true');
anchor.textContent = '#';
var link = documentRef.createElement('a');
link.setAttribute('href', '#toc-' + heading.textContent.replace(/\s+/g, '-').toLowerCase());
link.textContent = heading.textContent;
@ -45,7 +39,6 @@ function htmlTableOfContents (documentRef) {
var div = documentRef.createElement('div');
div.setAttribute('class', heading.tagName.toLowerCase() + '-toc');
heading.appendChild(anchor);
div.appendChild(link);
toc.appendChild(div);
});