0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-25 18:22:42 +00:00

Resolve indentation errors in TOC Generation, adjust partCover class

This fixes an error in the recusion that was failing to add children under existing parents.
Index generation now does not overindent when levels are skipped.
PartCover less code as suggesred by CC.
This commit is contained in:
David Bolack
2024-06-01 00:32:25 -05:00
parent fc22e6cd53
commit fbe65a4e93
2 changed files with 16 additions and 7 deletions

View File

@@ -12,11 +12,13 @@ const getTOC = (pages)=>{
children : []
});
} else {
child.push({
title : null,
page : page + 1,
children : []
});
if(child.length == 0) {
child.push({
title : null,
page : page + 1,
children : []
});
}
recursiveAdd(title, page, targetDepth, _.last(child).children, curDepth+1,);
}
};
@@ -41,14 +43,14 @@ const getTOC = (pages)=>{
const ToCIterate = (entries, curDepth=0)=>{
const levelPad = ['- ###', ' - ####', ' - ####', ' - ####', ' - ####', ' - ####'];
const levelPad = ['- ###', ' - ####', ' - ', ' - ', ' - ', ' - '];
const toc = [];
if(entries.title !== null){
toc.push(`${levelPad[curDepth]} [{{ ${entries.title}}}{{ ${entries.page}}}](#p${entries.page})`);
}
if(entries.children.length) {
_.each(entries.children, (entry, idx)=>{
const children = ToCIterate(entry, curDepth+1);
const children = ToCIterate(entry, entry.title == null ? curDepth : curDepth+1);
if(children.length) {
toc.push(...children);
}

View File

@@ -812,6 +812,13 @@ h6,
.tocIncludeH5 h5 {--TOC: include; }
.tocIncludeH6 h6 {--TOC: include; }
.page:has(.partCover) {
--TOC: exclude;
&h1 {
--TOC: include;
}
}
.page {
&:has(.toc)::after { display : none; }
.toc {