mirror of
https://github.com/danpros/htmly.git
synced 2026-04-19 03:56:21 +05:30
Styling the TOC
This commit is contained in:
parent
270b7f8e58
commit
8da38da937
10 changed files with 371 additions and 9 deletions
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue