0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-11 13:22:39 +00:00

Slight reworking of style naming for Table of Contents

Also uses :is operator for cleaner? looking CSS

Lastly, removes {{partCover}} from automatic exclusion.
This commit is contained in:
David Bolack
2024-05-22 16:30:12 -05:00
parent d9d4d74b71
commit 3ae5d4c1e3
3 changed files with 23 additions and 24 deletions

View File

@@ -27,7 +27,7 @@ const getTOC = (pages)=>{
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
const headings = iframeDocument.querySelectorAll('h1, h2, h3, h4, h5, h6');
const headerDepth = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
const exclusionElements = iframeDocument.querySelectorAll('frontCover insideCover partCover backCover');
const exclusionElements = iframeDocument.querySelectorAll('frontCover insideCover backCover');
const excludedPages = [];
// Build a list of excluded pages.
@@ -40,7 +40,12 @@ const getTOC = (pages)=>{
const onPage = parseInt(heading.closest('.page,.phb').id?.replace(/^p/, ''));
const ToCExclude = getComputedStyle(heading).getPropertyValue('--TOC');
if((ToCExclude != 'exclude') && (!excludedPages.includes(onPage))) {
if(heading.tagName == 'H1') {
console.log(heading);
console.log(ToCExclude);
}
if(((ToCExclude != 'exclude') && (!excludedPages.includes(onPage)))) {
recursiveAdd(heading.innerText.trim(), onPage, headerDepth.indexOf(heading.tagName), res);
}
});