From fbe65a4e93ad86309eb1bc3ea41957937d7c9ece Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sat, 1 Jun 2024 00:32:25 -0500 Subject: [PATCH] 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. --- themes/V3/5ePHB/snippets/tableOfContents.gen.js | 16 +++++++++------- themes/V3/5ePHB/style.less | 7 +++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index c33530bd7..1ec778944 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -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); } diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 7ef50df34..8b805b760 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -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 {