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:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user