From 854c21639a1b30085613ed31439042554d0bdf82 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sat, 20 Jan 2024 11:58:17 -0600 Subject: [PATCH 01/45] CSS based ToC exclusion system either I am building the lookup incorrectly or Chrome is not letting me see variables via computedStyles. --- .../V3/5ePHB/snippets/tableOfContents.gen.js | 47 ++++++++++++------- themes/V3/5ePHB/style.less | 3 ++ 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index 97d82ed40..1be583ba1 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -1,7 +1,7 @@ const _ = require('lodash'); const dedent = require('dedent-tabs').default; -const getTOC = (pages)=>{ +const getTOC = ()=>{ const add1 = (title, page)=>{ res.push({ title : title, @@ -27,32 +27,45 @@ const getTOC = (pages)=>{ }); }; + const getParentPageNumber = (e)=>{ + let tE = e; + while (tE?.tagName != 'BODY') { + if((tE.className == 'page') || (tE.className.split(' ')?.includes('Page'))) { + // Test for excluded pages here. + return parseInt(tE.id.replace(/^p/, '')); + } + tE = tE.parentElement; + } + return -1; + }; + const res = []; - _.each(pages, (page, pageNum)=>{ - if(!page.includes("{{frontCover}}") && !page.includes("{{insideCover}}") && !page.includes("{{partCover}}") && !page.includes("{{backCover}}")) { - const lines = page.split('\n'); - _.each(lines, (line)=>{ - if(_.startsWith(line, '# ')){ - const title = line.replace('# ', ''); - add1(title, pageNum); + const iframe = document.getElementById('BrewRenderer'); + const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; + const headings = iframeDocument.querySelectorAll('h1, h2, h3'); + + _.each(headings, (heading)=>{ + const onPage = getParentPageNumber(heading); + if(getComputedStyle(heading).getPropertyValue('--TOC') != 'exclude') { + if(onPage != -1) { + const headingText = heading.innerText; + if(heading.tagName == 'H1') { + add1(headingText, onPage); } - if(_.startsWith(line, '## ')){ - const title = line.replace('## ', ''); - add2(title, pageNum); + if(heading.tagName == 'H2') { + add2(headingText, onPage); } - if(_.startsWith(line, '### ')){ - const title = line.replace('### ', ''); - add3(title, pageNum); + if(heading.tagName == 'H3') { + add3(headingText, onPage); } - }); + } } }); return res; }; module.exports = function(props){ - const pages = props.brew.text.split('\\page'); - const TOC = getTOC(pages); + const TOC = getTOC(); const markdown = _.reduce(TOC, (r, g1, idx1)=>{ if(g1.title !== null) { r.push(`- ### [{{ ${g1.title}}}{{ ${g1.page}}}](#p${g1.page})`); diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 6c6634ce7..fba45df42 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -314,6 +314,7 @@ border-image : @monsterBorderImage 14 round; border-image-outset : 0px 2px; box-shadow : 1px 4px 14px #888888; + --TOC : "exclude"; } position : relative; @@ -329,11 +330,13 @@ margin-bottom : 0; font-size : 0.304cm; //Monster size and type subtext } + --TOC : "exclude"; } h3 { font-family : 'ScalySansSmallCapsRemake'; font-size : 0.45cm; border-bottom : 1.5px solid var(--HB_Color_HeaderText); + --TOC : "exclude"; } //Triangle dividers From 622827efda8de694d1fd428ef5cdcb073b717133 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sat, 20 Jan 2024 20:47:27 -0600 Subject: [PATCH 02/45] Fix Exclusion examination --- themes/V3/5ePHB/snippets/tableOfContents.gen.js | 17 +++-------------- themes/V3/5ePHB/style.less | 10 ++++++++++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index 1be583ba1..c6ac0671d 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -27,26 +27,15 @@ const getTOC = ()=>{ }); }; - const getParentPageNumber = (e)=>{ - let tE = e; - while (tE?.tagName != 'BODY') { - if((tE.className == 'page') || (tE.className.split(' ')?.includes('Page'))) { - // Test for excluded pages here. - return parseInt(tE.id.replace(/^p/, '')); - } - tE = tE.parentElement; - } - return -1; - }; - const res = []; const iframe = document.getElementById('BrewRenderer'); const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; const headings = iframeDocument.querySelectorAll('h1, h2, h3'); _.each(headings, (heading)=>{ - const onPage = getParentPageNumber(heading); - if(getComputedStyle(heading).getPropertyValue('--TOC') != 'exclude') { + const onPage = parseInt(heading.closest('.page,.phb').id.replace(/^p/, '')); + const ToCExclude = getComputedStyle(heading).getPropertyValue('--TOC'); + if(ToCExclude != '"exclude"') { if(onPage != -1) { const headingText = heading.innerText; if(heading.tagName == 'H1') { diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index fba45df42..03dc021c7 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -799,6 +799,16 @@ // ***************************** // * TABLE OF CONTENTS // *****************************/ + +.page:has(.frontCover), +.page:has(.backCover), +.page:has(.insideCover), +.page:has(.partCover), +.monster h3, +.monster h4, +h5, h6, +.toc { --TOC: exclude; } + .page { &:has(.toc)::after { display : none; } .toc { From 26c4b1afa6ccd4c061a7fdd4c2698a0f7742b0e8 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sun, 21 Jan 2024 08:58:14 -0600 Subject: [PATCH 03/45] Add toggle-on classes. --- themes/V3/5ePHB/style.less | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 03dc021c7..5c7771350 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -314,7 +314,6 @@ border-image : @monsterBorderImage 14 round; border-image-outset : 0px 2px; box-shadow : 1px 4px 14px #888888; - --TOC : "exclude"; } position : relative; @@ -330,13 +329,11 @@ margin-bottom : 0; font-size : 0.304cm; //Monster size and type subtext } - --TOC : "exclude"; } h3 { font-family : 'ScalySansSmallCapsRemake'; font-size : 0.45cm; border-bottom : 1.5px solid var(--HB_Color_HeaderText); - --TOC : "exclude"; } //Triangle dividers @@ -800,15 +797,22 @@ // * TABLE OF CONTENTS // *****************************/ +// Default Exclusions .page:has(.frontCover), .page:has(.backCover), .page:has(.insideCover), .page:has(.partCover), -.monster h3, -.monster h4, -h5, h6, +.monster, +.noToC, .toc { --TOC: exclude; } +// Manual Inclusion classes + +.addToC, +.addh1, .addh2, .addh3, .addh4, .addh5, .addh6, .addh1h2 h1, .addh1h2 h2, +.addh1h3 h1, .addh1h3 h2, .addh1h3 h3, .addh1h4 h1, .addh1h4 h2, .addh1h4 h3, .addh1h4 h4, +.addh1h5 h1, .addh1h5 h2, .addh1h5 h3, .addh1h5 h4, .addh1h5 h5 { --TOC: include; } + .page { &:has(.toc)::after { display : none; } .toc { From b8ee696b69cd676c3adb4982c773e8f543fa5358 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 24 Jan 2024 15:42:22 -0600 Subject: [PATCH 04/45] Add manual exclusion classes for ToC exclusion. --- themes/V3/5ePHB/style.less | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 5c7771350..a06817566 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -813,6 +813,11 @@ .addh1h3 h1, .addh1h3 h2, .addh1h3 h3, .addh1h4 h1, .addh1h4 h2, .addh1h4 h3, .addh1h4 h4, .addh1h5 h1, .addh1h5 h2, .addh1h5 h3, .addh1h5 h4, .addh1h5 h5 { --TOC: include; } +// Manual Exclusion classes +.noh1, .noh2, .noh3, .noh4, .noh5, .noh6, .noh1h2 h1, .noh1h2 h2, +.noh1h3 h1, .noh1h3 h2, .noh1h3 h3, .noh1h4 h1, .noh1h4 h2, .noh1h4 h3, .noh1h4 h4, +.noh1h5 h1, .noh1h5 h2, .noh1h5 h3, .noh1h5 h4, .noh1h5 h5 { --TOC: exclude; } + .page { &:has(.toc)::after { display : none; } .toc { From 85caf0a892644e6bf85129b1a763323334025f4f Mon Sep 17 00:00:00 2001 From: David Bolack Date: Mon, 29 Jan 2024 20:14:52 -0600 Subject: [PATCH 05/45] Add fixes to account for no page numbers Clear out manual toggles. --- themes/V3/5ePHB/snippets/tableOfContents.gen.js | 4 ++-- themes/V3/5ePHB/style.less | 12 ------------ 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index c6ac0671d..150b67c30 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -33,10 +33,10 @@ const getTOC = ()=>{ const headings = iframeDocument.querySelectorAll('h1, h2, h3'); _.each(headings, (heading)=>{ - const onPage = parseInt(heading.closest('.page,.phb').id.replace(/^p/, '')); + const onPage = parseInt(heading.closest('.page,.phb').id?.replace(/^p/, '')); const ToCExclude = getComputedStyle(heading).getPropertyValue('--TOC'); if(ToCExclude != '"exclude"') { - if(onPage != -1) { + if(!isNaN(onPage)) { const headingText = heading.innerText; if(heading.tagName == 'H1') { add1(headingText, onPage); diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index a06817566..1047ed729 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -806,18 +806,6 @@ .noToC, .toc { --TOC: exclude; } -// Manual Inclusion classes - -.addToC, -.addh1, .addh2, .addh3, .addh4, .addh5, .addh6, .addh1h2 h1, .addh1h2 h2, -.addh1h3 h1, .addh1h3 h2, .addh1h3 h3, .addh1h4 h1, .addh1h4 h2, .addh1h4 h3, .addh1h4 h4, -.addh1h5 h1, .addh1h5 h2, .addh1h5 h3, .addh1h5 h4, .addh1h5 h5 { --TOC: include; } - -// Manual Exclusion classes -.noh1, .noh2, .noh3, .noh4, .noh5, .noh6, .noh1h2 h1, .noh1h2 h2, -.noh1h3 h1, .noh1h3 h2, .noh1h3 h3, .noh1h4 h1, .noh1h4 h2, .noh1h4 h3, .noh1h4 h4, -.noh1h5 h1, .noh1h5 h2, .noh1h5 h3, .noh1h5 h4, .noh1h5 h5 { --TOC: exclude; } - .page { &:has(.toc)::after { display : none; } .toc { From 1705e66be2ac52cef7b6ba2349f1725522427cf9 Mon Sep 17 00:00:00 2001 From: dbolack Date: Sat, 23 Mar 2024 18:57:53 -0500 Subject: [PATCH 06/45] Corrections per PR Remove off by one error realted to change in page number detection. Dewrap quotes from exclude screen. --- themes/V3/5ePHB/snippets/tableOfContents.gen.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index c12205c69..d43ff3854 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -5,7 +5,7 @@ const getTOC = ()=>{ const add1 = (title, page)=>{ res.push({ title : title, - page : page + 1, + page : page, children : [] }); }; @@ -13,7 +13,7 @@ const getTOC = ()=>{ if(!_.last(res)) add1(null, page); _.last(res).children.push({ title : title, - page : page + 1, + page : page, children : [] }); }; @@ -22,7 +22,7 @@ const getTOC = ()=>{ if(!_.last(_.last(res).children)) add2(null, page); _.last(_.last(res).children).children.push({ title : title, - page : page + 1, + page : page, children : [] }); }; @@ -35,7 +35,7 @@ const getTOC = ()=>{ _.each(headings, (heading)=>{ const onPage = parseInt(heading.closest('.page,.phb').id?.replace(/^p/, '')); const ToCExclude = getComputedStyle(heading).getPropertyValue('--TOC'); - if(ToCExclude != '"exclude"') { + if(ToCExclude != 'exclude') { if(!isNaN(onPage)) { const headingText = heading.innerText; if(heading.tagName == 'H1') { From 7ca10ff5a48510fe6593fb77fa9fa5ed20232394 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Mon, 25 Mar 2024 16:13:07 -0500 Subject: [PATCH 07/45] Add requested additions to code Add snippet additions to handle Add h4, Add h4-h5, add h4-h6 Add collection of headers h4-h6 and rendering of h4 to h6. --- themes/V3/5ePHB/snippets.js | 31 ++++++- .../V3/5ePHB/snippets/tableOfContents.gen.js | 81 +++++++++++++++++-- themes/V3/5ePHB/style.less | 16 ++++ 3 files changed, 120 insertions(+), 8 deletions(-) diff --git a/themes/V3/5ePHB/snippets.js b/themes/V3/5ePHB/snippets.js index c0933d70d..c8b3dbde1 100644 --- a/themes/V3/5ePHB/snippets.js +++ b/themes/V3/5ePHB/snippets.js @@ -21,9 +21,34 @@ module.exports = [ view : 'text', snippets : [ { - name : 'Table of Contents', - icon : 'fas fa-book', - gen : TableOfContentsGen + name : 'Table of Contents', + icon : 'fas fa-book', + gen : TableOfContentsGen, + subsnippets : [ + { + name : 'Table of Contents', + icon : 'fas fa-book', + gen : TableOfContentsGen, + }, + { + name : 'Include H4', + icon : 'fas fa-dice-four', + gen : dedent `{{tocH4 + }}`, + }, + { + name : 'Include H4, H5', + icon : 'fas fa-dice-five', + gen : dedent `{{tocH5 + }}`, + }, + { + name : 'Include H4-H6', + icon : 'fas fa-dice-six', + gen : dedent `{{tocH6 + }}`, + }, + ] }, { name : 'Index', diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index d43ff3854..2d3865bbf 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -26,11 +26,44 @@ const getTOC = ()=>{ children : [] }); }; + const add4 = (title, page)=>{ + if(!_.last(res)) add1(null, page); + if(!_.last(_.last(res).children)) add2(null, page); + if(!_.last(!_.last(_.last(res).children))) add3(null, page); + _.last(_.last(_.last(res).children).children).children.push({ + title : title, + page : page, + children : [] + }); + }; + const add5 = (title, page)=>{ + if(!_.last(res)) add1(null, page); + if(!_.last(_.last(res).children)) add2(null, page); + if(!_.last(!_.last(_.last(res).children))) add3(null, page); + if(!_.last(!_.last(!_.last(_.last(res).children)))) add4(null, page); + _.last(_.last(_.last(_.last(res).children).children).children).children.push({ + title : title, + page : page, + children : [] + }); + }; + const add6 = (title, page)=>{ + if(!_.last(res)) add1(null, page); + if(!_.last(_.last(res).children)) add2(null, page); + if(!_.last(!_.last(_.last(res).children))) add3(null, page); + if(!_.last(!_.last(!_.last(_.last(res).children)))) add4(null, page); + if(!_.last(!_.last(!_.last(!_.last(_.last(res).children))))) add5(null, page); + _.last(_.last(_.last(_.last(_.last(res).children).children).children).children).children.push({ + title : title, + page : page, + children : [] + }); + }; const res = []; const iframe = document.getElementById('BrewRenderer'); const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; - const headings = iframeDocument.querySelectorAll('h1, h2, h3'); + const headings = iframeDocument.querySelectorAll('h1, h2, h3, h4, h5, h6'); _.each(headings, (heading)=>{ const onPage = parseInt(heading.closest('.page,.phb').id?.replace(/^p/, '')); @@ -47,6 +80,15 @@ const getTOC = ()=>{ if(heading.tagName == 'H3') { add3(headingText, onPage); } + if(heading.tagName == 'H4') { + add4(headingText, onPage); + } + if(heading.tagName == 'H5') { + add5(headingText, onPage); + } + if(heading.tagName == 'H6') { + add6(headingText, onPage); + } } } }); @@ -66,11 +108,40 @@ module.exports = function(props){ } if(g2.children.length){ _.each(g2.children, (g3, idx3)=>{ - if(g2.title !== null) { - r.push(` - [{{ ${g3.title}}}{{ ${g3.page}}}](#p${g3.page})`); - } else { // Don't over-indent if no level-2 parent entry - r.push(` - [{{ ${g3.title}}}{{ ${g3.page}}}](#p${g3.page})`); + if(g3.title !== null) { + if(g2.title !== null) { + r.push(` - [{{ ${g3.title}}}{{ ${g3.page}}}](#p${g3.page})`); + } else { // Don't over-indent if no level-2 parent entry + r.push(` - [{{ ${g3.title}}}{{ ${g3.page}}}](#p${g3.page})`); + } } + _.each(g3.children, (g4, idx4)=>{ + if(g4.title !== null) { + if(g3.title !== null) { + r.push(` - [{{ ${g4.title}}}{{ ${g4.page}}}](#p${g4.page})`); + } else { // Don't over-indent if no level-3 parent entry + r.push(` - [{{ ${g4.title}}}{{ ${g4.page}}}](#p${g4.page})`); + } + } + _.each(g4.children, (g5, idx5)=>{ + if(g5.title !== null) { + if(g4.title !== null) { + r.push(` - [{{ ${g5.title}}}{{ ${g5.page}}}](#p${g5.page})`); + } else { // Don't over-indent if no level-4 parent entry + r.push(` - [{{ ${g5.title}}}{{ ${g5.page}}}](#p${g5.page})`); + } + } + _.each(g5.children, (g6, idx6)=>{ + if(g6.title !== null) { + if(g5.title !== null) { + r.push(` - [{{ ${g6.title}}}{{ ${g6.page}}}](#p${g6.page})`); + } else { // Don't over-indent if no level-5 parent entry + r.push(` - [{{ ${g6.title}}}{{ ${g6.page}}}](#p${g6.page})`); + } + } + }); + }); + }); }); } }); diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index ceb811a23..4473ab7f8 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -791,6 +791,9 @@ // *****************************/ // Default Exclusions +h4, +h5, +h6, .page:has(.frontCover), .page:has(.backCover), .page:has(.insideCover), @@ -799,6 +802,19 @@ .noToC, .toc { --TOC: exclude; } +.tocH4 { + h4 { --TOC: include; } +} +.tocH5 { + h4 { --TOC: include; } + h5 { --TOC: include; } +} +.tocH6 { + h4 { --TOC: include; } + h5 { --TOC: include; } + h6 { --TOC: include; } +} + .page { &:has(.toc)::after { display : none; } .toc { From 40d0e7e90ed215449d604afb98774fa864cd9748 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Mon, 25 Mar 2024 16:32:03 -0500 Subject: [PATCH 08/45] Trim space off of ToC entries. --- themes/V3/5ePHB/snippets/tableOfContents.gen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index 2d3865bbf..cd8ac1e4e 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -70,7 +70,7 @@ const getTOC = ()=>{ const ToCExclude = getComputedStyle(heading).getPropertyValue('--TOC'); if(ToCExclude != 'exclude') { if(!isNaN(onPage)) { - const headingText = heading.innerText; + const headingText = heading.innerText.trim(); if(heading.tagName == 'H1') { add1(headingText, onPage); } From 9d3f7fe55673b0692b2225ca9e7f6f9d93f660b4 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Mon, 25 Mar 2024 18:58:29 -0500 Subject: [PATCH 09/45] Fix H3-H6 entries in ToC generation --- themes/V3/5ePHB/snippets/tableOfContents.gen.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index cd8ac1e4e..7c5cae7d3 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -110,33 +110,33 @@ module.exports = function(props){ _.each(g2.children, (g3, idx3)=>{ if(g3.title !== null) { if(g2.title !== null) { - r.push(` - [{{ ${g3.title}}}{{ ${g3.page}}}](#p${g3.page})`); + r.push(` - #### [{{ ${g3.title}}}{{ ${g3.page}}}](#p${g3.page})`); } else { // Don't over-indent if no level-2 parent entry - r.push(` - [{{ ${g3.title}}}{{ ${g3.page}}}](#p${g3.page})`); + r.push(` - #### [{{ ${g3.title}}}{{ ${g3.page}}}](#p${g3.page})`); } } _.each(g3.children, (g4, idx4)=>{ if(g4.title !== null) { if(g3.title !== null) { - r.push(` - [{{ ${g4.title}}}{{ ${g4.page}}}](#p${g4.page})`); + r.push(` - #### [{{ ${g4.title}}}{{ ${g4.page}}}](#p${g4.page})`); } else { // Don't over-indent if no level-3 parent entry - r.push(` - [{{ ${g4.title}}}{{ ${g4.page}}}](#p${g4.page})`); + r.push(` - #### [{{ ${g4.title}}}{{ ${g4.page}}}](#p${g4.page})`); } } _.each(g4.children, (g5, idx5)=>{ if(g5.title !== null) { if(g4.title !== null) { - r.push(` - [{{ ${g5.title}}}{{ ${g5.page}}}](#p${g5.page})`); + r.push(` - #### [{{ ${g5.title}}}{{ ${g5.page}}}](#p${g5.page})`); } else { // Don't over-indent if no level-4 parent entry - r.push(` - [{{ ${g5.title}}}{{ ${g5.page}}}](#p${g5.page})`); + r.push(` - #### [{{ ${g5.title}}}{{ ${g5.page}}}](#p${g5.page})`); } } _.each(g5.children, (g6, idx6)=>{ if(g6.title !== null) { if(g5.title !== null) { - r.push(` - [{{ ${g6.title}}}{{ ${g6.page}}}](#p${g6.page})`); + r.push(` - #### [{{ ${g6.title}}}{{ ${g6.page}}}](#p${g6.page})`); } else { // Don't over-indent if no level-5 parent entry - r.push(` - [{{ ${g6.title}}}{{ ${g6.page}}}](#p${g6.page})`); + r.push(` - #### [{{ ${g6.title}}}{{ ${g6.page}}}](#p${g6.page})`); } } }); From 211fe48e290cf649530936ad6d54a6ac4ec57cd1 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Mon, 25 Mar 2024 19:06:38 -0500 Subject: [PATCH 10/45] Attempt to block H4-h6 from existing ToCs from showing up in a new ToC. --- themes/V3/5ePHB/style.less | 3 +++ 1 file changed, 3 insertions(+) diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 4473ab7f8..9898bff0b 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -831,6 +831,9 @@ h6, text-decoration : none; &:hover { text-decoration : underline; } } + h1, h2, h3, h4, h5, h6 { + --TOC: exclude !important; + } h4 { margin-top : 0.2cm; line-height : 0.4cm; From 733b9299404888a6cb317ce5726f05e8dd3cf158 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Mon, 25 Mar 2024 19:36:30 -0500 Subject: [PATCH 11/45] Integrate code recursion from 3254. --- .../V3/5ePHB/snippets/tableOfContents.gen.js | 66 +++++-------------- 1 file changed, 18 insertions(+), 48 deletions(-) diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index 7c5cae7d3..0ae0213cc 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -95,57 +95,27 @@ const getTOC = ()=>{ return res; }; +const ToCIterate = (entries, curDepth=0)=>{ + 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); + if(children.length) { + toc.push(...children); + } + }); + } + return toc; +}; + module.exports = function(props){ const TOC = getTOC(); const markdown = _.reduce(TOC, (r, g1, idx1)=>{ - if(g1.title !== null) { - r.push(`- ### [{{ ${g1.title}}}{{ ${g1.page}}}](#p${g1.page})`); - } - if(g1.children.length){ - _.each(g1.children, (g2, idx2)=>{ - if(g2.title !== null) { - r.push(` - #### [{{ ${g2.title}}}{{ ${g2.page}}}](#p${g2.page})`); - } - if(g2.children.length){ - _.each(g2.children, (g3, idx3)=>{ - if(g3.title !== null) { - if(g2.title !== null) { - r.push(` - #### [{{ ${g3.title}}}{{ ${g3.page}}}](#p${g3.page})`); - } else { // Don't over-indent if no level-2 parent entry - r.push(` - #### [{{ ${g3.title}}}{{ ${g3.page}}}](#p${g3.page})`); - } - } - _.each(g3.children, (g4, idx4)=>{ - if(g4.title !== null) { - if(g3.title !== null) { - r.push(` - #### [{{ ${g4.title}}}{{ ${g4.page}}}](#p${g4.page})`); - } else { // Don't over-indent if no level-3 parent entry - r.push(` - #### [{{ ${g4.title}}}{{ ${g4.page}}}](#p${g4.page})`); - } - } - _.each(g4.children, (g5, idx5)=>{ - if(g5.title !== null) { - if(g4.title !== null) { - r.push(` - #### [{{ ${g5.title}}}{{ ${g5.page}}}](#p${g5.page})`); - } else { // Don't over-indent if no level-4 parent entry - r.push(` - #### [{{ ${g5.title}}}{{ ${g5.page}}}](#p${g5.page})`); - } - } - _.each(g5.children, (g6, idx6)=>{ - if(g6.title !== null) { - if(g5.title !== null) { - r.push(` - #### [{{ ${g6.title}}}{{ ${g6.page}}}](#p${g6.page})`); - } else { // Don't over-indent if no level-5 parent entry - r.push(` - #### [{{ ${g6.title}}}{{ ${g6.page}}}](#p${g6.page})`); - } - } - }); - }); - }); - }); - } - }); - } + r.push(ToCIterate(g1).join('\n')); return r; }, []).join('\n'); From cdf5b29ac2c6e902bb4a64992a04d4087ce8599b Mon Sep 17 00:00:00 2001 From: David Bolack Date: Mon, 25 Mar 2024 19:38:26 -0500 Subject: [PATCH 12/45] Remove !important from toc.h4/h5/h6 --TOC --- themes/V3/5ePHB/style.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 9898bff0b..1dd41237c 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -832,7 +832,7 @@ h6, &:hover { text-decoration : underline; } } h1, h2, h3, h4, h5, h6 { - --TOC: exclude !important; + --TOC: exclude; } h4 { margin-top : 0.2cm; From 7690fb9287c4576bb75cd80cf6615ba65f7ff3c6 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Tue, 26 Mar 2024 09:39:15 -0500 Subject: [PATCH 13/45] Return .addToC for inline mustaches --- themes/V3/5ePHB/style.less | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 1dd41237c..849786b3e 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -815,6 +815,8 @@ h6, h6 { --TOC: include; } } +.addToC { --TOC: include; } + .page { &:has(.toc)::after { display : none; } .toc { From 90ce48b170501cacc125c0ed4c74fbb469b15c2b Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sat, 20 Apr 2024 21:46:32 -0500 Subject: [PATCH 14/45] Adapt Recursive Toc function from 3254 --- .../V3/5ePHB/snippets/tableOfContents.gen.js | 128 +++++++----------- 1 file changed, 48 insertions(+), 80 deletions(-) diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index 0ae0213cc..56873aeb6 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -1,100 +1,67 @@ const _ = require('lodash'); const dedent = require('dedent-tabs').default; -const getTOC = ()=>{ - const add1 = (title, page)=>{ - res.push({ - title : title, - page : page, - children : [] - }); - }; - const add2 = (title, page)=>{ - if(!_.last(res)) add1(null, page); - _.last(res).children.push({ - title : title, - page : page, - children : [] - }); - }; - const add3 = (title, page)=>{ - if(!_.last(res)) add1(null, page); - if(!_.last(_.last(res).children)) add2(null, page); - _.last(_.last(res).children).children.push({ - title : title, - page : page, - children : [] - }); - }; - const add4 = (title, page)=>{ - if(!_.last(res)) add1(null, page); - if(!_.last(_.last(res).children)) add2(null, page); - if(!_.last(!_.last(_.last(res).children))) add3(null, page); - _.last(_.last(_.last(res).children).children).children.push({ - title : title, - page : page, - children : [] - }); - }; - const add5 = (title, page)=>{ - if(!_.last(res)) add1(null, page); - if(!_.last(_.last(res).children)) add2(null, page); - if(!_.last(!_.last(_.last(res).children))) add3(null, page); - if(!_.last(!_.last(!_.last(_.last(res).children)))) add4(null, page); - _.last(_.last(_.last(_.last(res).children).children).children).children.push({ - title : title, - page : page, - children : [] - }); - }; - const add6 = (title, page)=>{ - if(!_.last(res)) add1(null, page); - if(!_.last(_.last(res).children)) add2(null, page); - if(!_.last(!_.last(_.last(res).children))) add3(null, page); - if(!_.last(!_.last(!_.last(_.last(res).children)))) add4(null, page); - if(!_.last(!_.last(!_.last(!_.last(_.last(res).children))))) add5(null, page); - _.last(_.last(_.last(_.last(_.last(res).children).children).children).children).children.push({ - title : title, - page : page, - children : [] - }); +const getTOC = (pages)=>{ + + const recursiveAdd = (title, page, targetDepth, child, curDepth=0)=>{ + console.log(curDepth); + if(curDepth > 5) return; // Something went wrong. + if(curDepth == targetDepth) { + child.push({ + title : title, + page : page + 1, + children : [] + }); + } else { + console.log(typeof child); + child.push({ + title : null, + page : page + 1, + children : [] + }); + console.log(_.last(child)); + console.log(_.last(child).children); + recursiveAdd(title, page, targetDepth, _.last(child).children, curDepth+1,); + } }; const res = []; - const iframe = document.getElementById('BrewRenderer'); - const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; - const headings = iframeDocument.querySelectorAll('h1, h2, h3, h4, h5, h6'); - _.each(headings, (heading)=>{ - const onPage = parseInt(heading.closest('.page,.phb').id?.replace(/^p/, '')); - const ToCExclude = getComputedStyle(heading).getPropertyValue('--TOC'); - if(ToCExclude != 'exclude') { - if(!isNaN(onPage)) { - const headingText = heading.innerText.trim(); - if(heading.tagName == 'H1') { - add1(headingText, onPage); + _.each(pages, (page, pageNum)=>{ + if(!page.includes("{{frontCover}}") && !page.includes("{{insideCover}}") && !page.includes("{{partCover}}") && !page.includes("{{backCover}}")) { + const lines = page.split('\n'); + _.each(lines, (line)=>{ + if(_.startsWith(line, '# ')){ + const title = line.replace('# ', ''); + recursiveAdd(title, pageNum, 0, res); } - if(heading.tagName == 'H2') { - add2(headingText, onPage); + if(_.startsWith(line, '## ')){ + const title = line.replace('## ', ''); + recursiveAdd(title, pageNum, 1, res); } - if(heading.tagName == 'H3') { - add3(headingText, onPage); + if(_.startsWith(line, '### ')){ + const title = line.replace('### ', ''); + recursiveAdd(title, pageNum, 2, res); } - if(heading.tagName == 'H4') { - add4(headingText, onPage); + if(_.startsWith(line, '#### ')){ + const title = line.replace('#### ', ''); + recursiveAdd(title, pageNum, 3, res); } - if(heading.tagName == 'H5') { - add5(headingText, onPage); + if(_.startsWith(line, '##### ')){ + const title = line.replace('##### ', ''); + recursiveAdd(title, pageNum, 4, res); } - if(heading.tagName == 'H6') { - add6(headingText, onPage); + if(_.startsWith(line, '##### ')){ + const title = line.replace('##### ', ''); + recursiveAdd(title, pageNum, 5, res); } - } + }); } }); return res; }; + const ToCIterate = (entries, curDepth=0)=>{ const levelPad = ['- ###', ' - ####', ' - ####', ' - ####', ' - ####', ' - ####']; const toc = []; @@ -113,7 +80,8 @@ const ToCIterate = (entries, curDepth=0)=>{ }; module.exports = function(props){ - const TOC = getTOC(); + const pages = props.brew.text.split('\\page'); + const TOC = getTOC(pages); const markdown = _.reduce(TOC, (r, g1, idx1)=>{ r.push(ToCIterate(g1).join('\n')); return r; From 2a148cb138a57a1c6d59eab64fbacd5d15ad3035 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sat, 20 Apr 2024 21:53:02 -0500 Subject: [PATCH 15/45] Update Menus and standardize CSS Names Update addh4, addh5, addh6 class names to addToCH4, addToCH5, addToCH6 Update menu items for Table of contents with better labels and addToC --- themes/V3/5ePHB/snippets.js | 19 +++++++++++++------ themes/V3/5ePHB/style.less | 6 +++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/themes/V3/5ePHB/snippets.js b/themes/V3/5ePHB/snippets.js index c8b3dbde1..081ab3ef3 100644 --- a/themes/V3/5ePHB/snippets.js +++ b/themes/V3/5ePHB/snippets.js @@ -31,23 +31,30 @@ module.exports = [ gen : TableOfContentsGen, }, { - name : 'Include H4', + name : 'Include up to H4', icon : 'fas fa-dice-four', - gen : dedent `{{tocH4 + gen : dedent `{{addToCH4 }}`, }, { - name : 'Include H4, H5', + name : 'Include up to H5', icon : 'fas fa-dice-five', - gen : dedent `{{tocH5 + gen : dedent `{{addToCH5 }}`, }, { - name : 'Include H4-H6', + name : 'Include up to H6', icon : 'fas fa-dice-six', - gen : dedent `{{tocH6 + gen : dedent `{{addToCH6 }}`, }, + { + name : 'Include in ToC', + icon : 'fas fa-dice-six', + gen : dedent `{{addToC + }}`, + + } ] }, { diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index f90396401..9c0059ba8 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -802,14 +802,14 @@ h6, .noToC, .toc { --TOC: exclude; } -.tocH4 { +.addToCH4 { h4 { --TOC: include; } } -.tocH5 { +.addToCH5 { h4 { --TOC: include; } h5 { --TOC: include; } } -.tocH6 { +.addToCH6 { h4 { --TOC: include; } h5 { --TOC: include; } h6 { --TOC: include; } From c0beae6e46e2b52918dedaebdf27669955979e25 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sun, 12 May 2024 11:49:30 -0500 Subject: [PATCH 16/45] Remove redundant class declaration for ToC --- themes/V3/5ePHB/style.less | 3 --- 1 file changed, 3 deletions(-) diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index c65ed852f..06bc7b1ac 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -825,9 +825,6 @@ h6, text-decoration : none; &:hover { text-decoration : underline; } } - h1, h2, h3, h4, h5, h6 { - --TOC: exclude; - } h4 { margin-top : 0.2cm; line-height : 0.4cm; From afb5ccec8169ef960bae5b24741185ba2c94bf1b Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sun, 12 May 2024 12:00:55 -0500 Subject: [PATCH 17/45] Slight Rearrange of ToC theme names and menu Reorders ToC inclusion options with slight relabel for clarity. Changes assumptions on H4, H5, and H6 snippets to assume H1-H3 class should be explicitly stated. change naming of addToToCH# to tocH# more explicitly define .addToC to h1 to h3 changes for --TOC var. --- themes/V3/5ePHB/snippets.js | 38 ++++++++++++++++++------------------- themes/V3/5ePHB/style.less | 12 ++++++++---- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/themes/V3/5ePHB/snippets.js b/themes/V3/5ePHB/snippets.js index 081ab3ef3..149517fbb 100644 --- a/themes/V3/5ePHB/snippets.js +++ b/themes/V3/5ePHB/snippets.js @@ -31,29 +31,29 @@ module.exports = [ gen : TableOfContentsGen, }, { - name : 'Include up to H4', - icon : 'fas fa-dice-four', - gen : dedent `{{addToCH4 - }}`, - }, - { - name : 'Include up to H5', - icon : 'fas fa-dice-five', - gen : dedent `{{addToCH5 - }}`, - }, - { - name : 'Include up to H6', - icon : 'fas fa-dice-six', - gen : dedent `{{addToCH6 - }}`, - }, - { - name : 'Include in ToC', + name : 'Include in ToC up to H3', icon : 'fas fa-dice-six', gen : dedent `{{addToC }}`, + }, + { + name : 'Include in ToC up to H4', + icon : 'fas fa-dice-four', + gen : dedent `{{addToC,tocH4 + }}`, + }, + { + name : 'Include in ToC up to H5', + icon : 'fas fa-dice-five', + gen : dedent `{{addToC,tocH5 + }}`, + }, + { + name : 'Include in ToC up to H6', + icon : 'fas fa-dice-six', + gen : dedent `{{addToC,tocH6 + }}`, } ] }, diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 06bc7b1ac..41318cfe6 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -794,20 +794,24 @@ h6, .noToC, .toc { --TOC: exclude; } -.addToCH4 { +.tocH4 { h4 { --TOC: include; } } -.addToCH5 { +.tocH5 { h4 { --TOC: include; } h5 { --TOC: include; } } -.addToCH6 { +.tocH6 { h4 { --TOC: include; } h5 { --TOC: include; } h6 { --TOC: include; } } -.addToC { --TOC: include; } +.addToC { + h1 {--TOC: include; } + h2 {--TOC: include; } + h3 {--TOC: include; } +} .page { &:has(.toc)::after { display : none; } From 1773e77cb9d0d32f1be509d2b6ce9ea2293a9c00 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 22 May 2024 11:47:12 -0500 Subject: [PATCH 18/45] Fix missed issues with converting to delightfully recursive function --- .../V3/5ePHB/snippets/tableOfContents.gen.js | 52 +++++++------------ 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index 56873aeb6..6bb87cbf1 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -4,7 +4,6 @@ const dedent = require('dedent-tabs').default; const getTOC = (pages)=>{ const recursiveAdd = (title, page, targetDepth, child, curDepth=0)=>{ - console.log(curDepth); if(curDepth > 5) return; // Something went wrong. if(curDepth == targetDepth) { child.push({ @@ -13,49 +12,36 @@ const getTOC = (pages)=>{ children : [] }); } else { - console.log(typeof child); child.push({ title : null, page : page + 1, children : [] }); - console.log(_.last(child)); - console.log(_.last(child).children); recursiveAdd(title, page, targetDepth, _.last(child).children, curDepth+1,); } }; const res = []; - _.each(pages, (page, pageNum)=>{ - if(!page.includes("{{frontCover}}") && !page.includes("{{insideCover}}") && !page.includes("{{partCover}}") && !page.includes("{{backCover}}")) { - const lines = page.split('\n'); - _.each(lines, (line)=>{ - if(_.startsWith(line, '# ')){ - const title = line.replace('# ', ''); - recursiveAdd(title, pageNum, 0, res); - } - if(_.startsWith(line, '## ')){ - const title = line.replace('## ', ''); - recursiveAdd(title, pageNum, 1, res); - } - if(_.startsWith(line, '### ')){ - const title = line.replace('### ', ''); - recursiveAdd(title, pageNum, 2, res); - } - if(_.startsWith(line, '#### ')){ - const title = line.replace('#### ', ''); - recursiveAdd(title, pageNum, 3, res); - } - if(_.startsWith(line, '##### ')){ - const title = line.replace('##### ', ''); - recursiveAdd(title, pageNum, 4, res); - } - if(_.startsWith(line, '##### ')){ - const title = line.replace('##### ', ''); - recursiveAdd(title, pageNum, 5, res); - } - }); + const iframe = document.getElementById('BrewRenderer'); + 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 excludedPages = []; + + // Build a list of excluded pages. + _.each(exclusionElements, (e)=>{ + const onPage = parseInt(e.closest('.page,.phb').id?.replace(/^p/, '')); + if(!excludedPages.includes(onPage)) excludedPages.push(onPage); + }); + + _.each(headings, (heading)=>{ + const onPage = parseInt(heading.closest('.page,.phb').id?.replace(/^p/, '')); + const ToCExclude = getComputedStyle(heading).getPropertyValue('--TOC'); + + if((ToCExclude != 'exclude') && (!excludedPages.includes(onPage))) { + recursiveAdd(heading.innerText.trim(), onPage, headerDepth.indexOf(heading.tagName), res); } }); return res; From d9d4d74b713489d3eba5c9e0ff515e57f38ee5bf Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 22 May 2024 12:44:19 -0500 Subject: [PATCH 19/45] Add CR wrappers around addTOC snippet insertions. --- themes/V3/5ePHB/snippets.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/themes/V3/5ePHB/snippets.js b/themes/V3/5ePHB/snippets.js index 149517fbb..5c93c8004 100644 --- a/themes/V3/5ePHB/snippets.js +++ b/themes/V3/5ePHB/snippets.js @@ -33,27 +33,27 @@ module.exports = [ { name : 'Include in ToC up to H3', icon : 'fas fa-dice-six', - gen : dedent `{{addToC - }}`, + gen : dedent `\n{{addToC + }}\n`, }, { name : 'Include in ToC up to H4', icon : 'fas fa-dice-four', - gen : dedent `{{addToC,tocH4 - }}`, + gen : dedent `\n{{addToC,tocH4 + }}\n`, }, { name : 'Include in ToC up to H5', icon : 'fas fa-dice-five', - gen : dedent `{{addToC,tocH5 - }}`, + gen : dedent `\n{{addToC,tocH5 + }}\n`, }, { name : 'Include in ToC up to H6', icon : 'fas fa-dice-six', - gen : dedent `{{addToC,tocH6 - }}`, + gen : dedent `\n{{addToC,tocH6 + }}\n`, } ] }, From 3ae5d4c1e311067ef75541bb4aa036fc47ce1c99 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 22 May 2024 16:30:12 -0500 Subject: [PATCH 20/45] Slight reworking of style naming for Table of Contents Also uses :is operator for cleaner? looking CSS Lastly, removes {{partCover}} from automatic exclusion. --- themes/V3/5ePHB/snippets.js | 8 ++--- .../V3/5ePHB/snippets/tableOfContents.gen.js | 9 ++++-- themes/V3/5ePHB/style.less | 30 ++++++++----------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/themes/V3/5ePHB/snippets.js b/themes/V3/5ePHB/snippets.js index 5c93c8004..2c18354b8 100644 --- a/themes/V3/5ePHB/snippets.js +++ b/themes/V3/5ePHB/snippets.js @@ -33,26 +33,26 @@ module.exports = [ { name : 'Include in ToC up to H3', icon : 'fas fa-dice-six', - gen : dedent `\n{{addToC + gen : dedent `\n{{tocH3 }}\n`, }, { name : 'Include in ToC up to H4', icon : 'fas fa-dice-four', - gen : dedent `\n{{addToC,tocH4 + gen : dedent `\n{{tocH4 }}\n`, }, { name : 'Include in ToC up to H5', icon : 'fas fa-dice-five', - gen : dedent `\n{{addToC,tocH5 + gen : dedent `\n{{tocH5 }}\n`, }, { name : 'Include in ToC up to H6', icon : 'fas fa-dice-six', - gen : dedent `\n{{addToC,tocH6 + gen : dedent `\n{{tocH6 }}\n`, } ] diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index 6bb87cbf1..9e8ed8040 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -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); } }); diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 0ba6062e9..68ea5eda9 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -794,29 +794,23 @@ h6, .page:has(.frontCover), .page:has(.backCover), .page:has(.insideCover), -.page:has(.partCover), .monster, .noToC, .toc { --TOC: exclude; } -.tocH4 { - h4 { --TOC: include; } -} -.tocH5 { - h4 { --TOC: include; } - h5 { --TOC: include; } -} -.tocH6 { - h4 { --TOC: include; } - h5 { --TOC: include; } - h6 { --TOC: include; } -} +.tocH1 :is(h1) { --TOC: include; } +.tocH2 :is(h1, h2) {--TOC: include; } +.tocH3 :is(h1, h2, h3) {--TOC: include; } +.tocH4 :is(h1, h2, h3, h4) {--TOC: include; } +.tocH5 :is(h1, h2, h3, h4, h5) {--TOC: include; } +.tocH6 :is(h1, h2, h3, h4, h5, h6) {--TOC: include; } -.addToC { - h1 {--TOC: include; } - h2 {--TOC: include; } - h3 {--TOC: include; } -} +.tocIncludeH1 h1 {--TOC: include; } +.tocIncludeH2 h2 {--TOC: include; } +.tocIncludeH3 h3 {--TOC: include; } +.tocIncludeH4 h4 {--TOC: include; } +.tocIncludeH5 h5 {--TOC: include; } +.tocIncludeH6 h6 {--TOC: include; } .page { &:has(.toc)::after { display : none; } From b496ef35978bdd3b616532d9563fad990327f01d Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 22 May 2024 16:34:00 -0500 Subject: [PATCH 21/45] Remove completely redundant checks for class based exclusion from ToC Snippet --- themes/V3/5ePHB/snippets/tableOfContents.gen.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index 9e8ed8040..66aab50bc 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -27,25 +27,12 @@ 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 backCover'); - const excludedPages = []; - - // Build a list of excluded pages. - _.each(exclusionElements, (e)=>{ - const onPage = parseInt(e.closest('.page,.phb').id?.replace(/^p/, '')); - if(!excludedPages.includes(onPage)) excludedPages.push(onPage); - }); _.each(headings, (heading)=>{ const onPage = parseInt(heading.closest('.page,.phb').id?.replace(/^p/, '')); const ToCExclude = getComputedStyle(heading).getPropertyValue('--TOC'); - if(heading.tagName == 'H1') { - console.log(heading); - console.log(ToCExclude); - } - - if(((ToCExclude != 'exclude') && (!excludedPages.includes(onPage)))) { + if(ToCExclude != 'exclude') { recursiveAdd(heading.innerText.trim(), onPage, headerDepth.indexOf(heading.tagName), res); } }); From 0df53daa4c2dbb09468e25309e23912a6fae14ee Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 22 May 2024 17:25:52 -0500 Subject: [PATCH 22/45] Another attempt at clearer classnames for the Table of contents snippet --- themes/V3/5ePHB/snippets.js | 8 ++++---- themes/V3/5ePHB/style.less | 23 +++++++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/themes/V3/5ePHB/snippets.js b/themes/V3/5ePHB/snippets.js index 2c18354b8..0aba0d11e 100644 --- a/themes/V3/5ePHB/snippets.js +++ b/themes/V3/5ePHB/snippets.js @@ -33,26 +33,26 @@ module.exports = [ { name : 'Include in ToC up to H3', icon : 'fas fa-dice-six', - gen : dedent `\n{{tocH3 + gen : dedent `\n{{tocAddH1H3 }}\n`, }, { name : 'Include in ToC up to H4', icon : 'fas fa-dice-four', - gen : dedent `\n{{tocH4 + gen : dedent `\n{{tocAddH1H4 }}\n`, }, { name : 'Include in ToC up to H5', icon : 'fas fa-dice-five', - gen : dedent `\n{{tocH5 + gen : dedent `\n{{tocAddH1H5 }}\n`, }, { name : 'Include in ToC up to H6', icon : 'fas fa-dice-six', - gen : dedent `\n{{tocH6 + gen : dedent `\n{{tocAddH1H6 }}\n`, } ] diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 68ea5eda9..0f34585f7 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -798,19 +798,18 @@ h6, .noToC, .toc { --TOC: exclude; } -.tocH1 :is(h1) { --TOC: include; } -.tocH2 :is(h1, h2) {--TOC: include; } -.tocH3 :is(h1, h2, h3) {--TOC: include; } -.tocH4 :is(h1, h2, h3, h4) {--TOC: include; } -.tocH5 :is(h1, h2, h3, h4, h5) {--TOC: include; } -.tocH6 :is(h1, h2, h3, h4, h5, h6) {--TOC: include; } +.tocAddH1H2 :is(h1, h2) {--TOC: include; } +.tocAddH1H3 :is(h1, h2, h3) {--TOC: include; } +.tocAddH1H4 :is(h1, h2, h3, h4) {--TOC: include; } +.tocAddH1H5 :is(h1, h2, h3, h4, h5) {--TOC: include; } +.tocAddH1H6 :is(h1, h2, h3, h4, h5, h6) {--TOC: include; } -.tocIncludeH1 h1 {--TOC: include; } -.tocIncludeH2 h2 {--TOC: include; } -.tocIncludeH3 h3 {--TOC: include; } -.tocIncludeH4 h4 {--TOC: include; } -.tocIncludeH5 h5 {--TOC: include; } -.tocIncludeH6 h6 {--TOC: include; } +.tocAddH1 h1 {--TOC: include; } +.tocAddH2 h2 {--TOC: include; } +.tocAddH3 h3 {--TOC: include; } +.tocAddH4 h4 {--TOC: include; } +.tocAddH5 h5 {--TOC: include; } +.tocAddH6 h6 {--TOC: include; } .page { &:has(.toc)::after { display : none; } From 7cef4316d78a19ef35ae383cc6cd9b7ad815fc60 Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 22 May 2024 21:04:32 -0500 Subject: [PATCH 23/45] Flag Table of Contents as "Experimental" --- themes/V3/5ePHB/snippets.js | 16 +++++++++------- themes/V3/5ePHB/snippets/tableOfContents.gen.js | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/themes/V3/5ePHB/snippets.js b/themes/V3/5ePHB/snippets.js index 0aba0d11e..adcfe95a5 100644 --- a/themes/V3/5ePHB/snippets.js +++ b/themes/V3/5ePHB/snippets.js @@ -21,14 +21,16 @@ module.exports = [ view : 'text', snippets : [ { - name : 'Table of Contents', - icon : 'fas fa-book', - gen : TableOfContentsGen, - subsnippets : [ + name : 'Table of Contents', + icon : 'fas fa-book', + gen : TableOfContentsGen, + experimental : true, + subsnippets : [ { - name : 'Table of Contents', - icon : 'fas fa-book', - gen : TableOfContentsGen, + name : 'Table of Contents', + icon : 'fas fa-book', + gen : TableOfContentsGen, + experimental : true }, { name : 'Include in ToC up to H3', diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index 66aab50bc..c33530bd7 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -29,7 +29,7 @@ const getTOC = (pages)=>{ const headerDepth = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6']; _.each(headings, (heading)=>{ - const onPage = parseInt(heading.closest('.page,.phb').id?.replace(/^p/, '')); + const onPage = parseInt(heading.closest('.page').id?.replace(/^p/, '')); const ToCExclude = getComputedStyle(heading).getPropertyValue('--TOC'); if(ToCExclude != 'exclude') { From 62ed026757c327a4673c68f874238e3c4928607d Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 22 May 2024 21:25:10 -0500 Subject: [PATCH 24/45] Hopeflly final class renaming sessions. --- themes/V3/5ePHB/snippets.js | 8 ++++---- themes/V3/5ePHB/style.less | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/themes/V3/5ePHB/snippets.js b/themes/V3/5ePHB/snippets.js index adcfe95a5..01ec1c700 100644 --- a/themes/V3/5ePHB/snippets.js +++ b/themes/V3/5ePHB/snippets.js @@ -35,26 +35,26 @@ module.exports = [ { name : 'Include in ToC up to H3', icon : 'fas fa-dice-six', - gen : dedent `\n{{tocAddH1H3 + gen : dedent `\n{{tocDepthH3 }}\n`, }, { name : 'Include in ToC up to H4', icon : 'fas fa-dice-four', - gen : dedent `\n{{tocAddH1H4 + gen : dedent `\n{{tocDepthH4 }}\n`, }, { name : 'Include in ToC up to H5', icon : 'fas fa-dice-five', - gen : dedent `\n{{tocAddH1H5 + gen : dedent `\n{{tocDepthH5 }}\n`, }, { name : 'Include in ToC up to H6', icon : 'fas fa-dice-six', - gen : dedent `\n{{tocAddH1H6 + gen : dedent `\n{{tocDepthH6 }}\n`, } ] diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 0f34585f7..674b29364 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -798,18 +798,18 @@ h6, .noToC, .toc { --TOC: exclude; } -.tocAddH1H2 :is(h1, h2) {--TOC: include; } -.tocAddH1H3 :is(h1, h2, h3) {--TOC: include; } -.tocAddH1H4 :is(h1, h2, h3, h4) {--TOC: include; } -.tocAddH1H5 :is(h1, h2, h3, h4, h5) {--TOC: include; } -.tocAddH1H6 :is(h1, h2, h3, h4, h5, h6) {--TOC: include; } +.tocDepthH2 :is(h1, h2) {--TOC: include; } +.tocDepthH3 :is(h1, h2, h3) {--TOC: include; } +.tocDepthH4 :is(h1, h2, h3, h4) {--TOC: include; } +.tocDepthH5 :is(h1, h2, h3, h4, h5) {--TOC: include; } +.tocDepthH6 :is(h1, h2, h3, h4, h5, h6) {--TOC: include; } -.tocAddH1 h1 {--TOC: include; } -.tocAddH2 h2 {--TOC: include; } -.tocAddH3 h3 {--TOC: include; } -.tocAddH4 h4 {--TOC: include; } -.tocAddH5 h5 {--TOC: include; } -.tocAddH6 h6 {--TOC: include; } +.tocIncludeH1 h1 {--TOC: include; } +.tocIncludeH2 h2 {--TOC: include; } +.tocIncludeH3 h3 {--TOC: include; } +.tocIncludeH4 h4 {--TOC: include; } +.tocIncludeH5 h5 {--TOC: include; } +.tocIncludeH6 h6 {--TOC: include; } .page { &:has(.toc)::after { display : none; } From fc22e6cd5376f5d8cf0a5eae72585105502c601f Mon Sep 17 00:00:00 2001 From: David Bolack Date: Wed, 22 May 2024 23:17:22 -0500 Subject: [PATCH 25/45] Smidge of documentation --- themes/V3/5ePHB/style.less | 1 + 1 file changed, 1 insertion(+) diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 674b29364..7ef50df34 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -788,6 +788,7 @@ // *****************************/ // Default Exclusions +// Anything not exlcuded is included, default Headers are H1, H2, and H3. h4, h5, h6, From 8fc224e9a10a18bf6c30dc732a6fb8204616596e Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Tue, 28 May 2024 17:33:52 -0400 Subject: [PATCH 26/45] Update themes/V3/5ePHB/snippets.js --- themes/V3/5ePHB/snippets.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/V3/5ePHB/snippets.js b/themes/V3/5ePHB/snippets.js index 01ec1c700..d5f37ac65 100644 --- a/themes/V3/5ePHB/snippets.js +++ b/themes/V3/5ePHB/snippets.js @@ -34,7 +34,7 @@ module.exports = [ }, { name : 'Include in ToC up to H3', - icon : 'fas fa-dice-six', + icon : 'fas fa-dice-three', gen : dedent `\n{{tocDepthH3 }}\n`, From fbe65a4e93ad86309eb1bc3ea41957937d7c9ece Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sat, 1 Jun 2024 00:32:25 -0500 Subject: [PATCH 27/45] 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 { From 9886200fa901ef1f0f3dccee68138acf8c1dc29f Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Fri, 28 Jun 2024 09:39:49 -0400 Subject: [PATCH 28/45] Fix partCover H1 inclusion rule --- themes/V3/5ePHB/style.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/V3/5ePHB/style.less b/themes/V3/5ePHB/style.less index 8b805b760..f8a14f46e 100644 --- a/themes/V3/5ePHB/style.less +++ b/themes/V3/5ePHB/style.less @@ -814,7 +814,7 @@ h6, .page:has(.partCover) { --TOC: exclude; - &h1 { + & h1 { --TOC: include; } } From 179e21755cb2f6ec274efeb1e2fc5ed0c9cc51da Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Fri, 28 Jun 2024 22:01:55 -0400 Subject: [PATCH 29/45] Unify some emoji CSS across fonts --- shared/naturalcrit/codeEditor/codeEditor.less | 1 + themes/V3/Blank/style.less | 1 + themes/fonts/iconFonts/diceFont.less | 7 +++++-- themes/fonts/iconFonts/elderberryInn.less | 9 +++++---- themes/fonts/iconFonts/fontAwesome.less | 2 ++ themes/fonts/iconFonts/gameIcons.less | 6 +----- 6 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 themes/fonts/iconFonts/fontAwesome.less diff --git a/shared/naturalcrit/codeEditor/codeEditor.less b/shared/naturalcrit/codeEditor/codeEditor.less index 0f29eff7b..cb73b0a88 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.less +++ b/shared/naturalcrit/codeEditor/codeEditor.less @@ -8,6 +8,7 @@ @import (less) './themes/fonts/iconFonts/diceFont.less'; @import (less) './themes/fonts/iconFonts/elderberryInn.less'; @import (less) './themes/fonts/iconFonts/gameIcons.less'; +@import (less) './themes/fonts/iconFonts/fontAwesome.less'; @keyframes sourceMoveAnimation { 50% {background-color: red; color: white;} diff --git a/themes/V3/Blank/style.less b/themes/V3/Blank/style.less index 24e87504f..0f779c38b 100644 --- a/themes/V3/Blank/style.less +++ b/themes/V3/Blank/style.less @@ -3,6 +3,7 @@ @import (less) './themes/fonts/iconFonts/elderberryInn.less'; @import (less) './themes/fonts/iconFonts/diceFont.less'; @import (less) './themes/fonts/iconFonts/gameIcons.less'; +@import (less) './themes/fonts/iconFonts/fontAwesome.less'; :root { //Colors diff --git a/themes/fonts/iconFonts/diceFont.less b/themes/fonts/iconFonts/diceFont.less index 6fe226a05..ec80f132b 100644 --- a/themes/fonts/iconFonts/diceFont.less +++ b/themes/fonts/iconFonts/diceFont.less @@ -7,7 +7,7 @@ } .df { - display : inline-block; + display : inline; font-family : 'DiceFont'; font-style : normal; font-weight : normal; @@ -16,8 +16,11 @@ text-decoration : inherit; text-transform : none; text-rendering : optimizeLegibility; - -moz-osx-font-smoothing : grayscale; + + /* Better Font Rendering =========== */ -webkit-font-smoothing : antialiased; + -moz-osx-font-smoothing : grayscale; + &.F::before { content : '\f190'; } &.F-minus::before { content : '\f191'; } &.F-plus::before { content : '\f192'; } diff --git a/themes/fonts/iconFonts/elderberryInn.less b/themes/fonts/iconFonts/elderberryInn.less index c956563fc..958d1b265 100644 --- a/themes/fonts/iconFonts/elderberryInn.less +++ b/themes/fonts/iconFonts/elderberryInn.less @@ -7,15 +7,16 @@ } .ei { - display : inline-block; - margin-right : 3px; + display : inline; font-family : 'Elderberry-Inn'; line-height : 1; vertical-align : baseline; - -moz-osx-font-smoothing : grayscale; - -webkit-font-smoothing : antialiased; text-rendering : auto; + /* Better Font Rendering =========== */ + -webkit-font-smoothing : antialiased; + -moz-osx-font-smoothing : grayscale; + &.book::before { content : '\E900'; } &.screen::before { content : '\E901'; } diff --git a/themes/fonts/iconFonts/fontAwesome.less b/themes/fonts/iconFonts/fontAwesome.less new file mode 100644 index 000000000..5f626c645 --- /dev/null +++ b/themes/fonts/iconFonts/fontAwesome.less @@ -0,0 +1,2 @@ +/* Icon Font: Font Awesome */ +.far,.fas,.fab { display : inline; } \ No newline at end of file diff --git a/themes/fonts/iconFonts/gameIcons.less b/themes/fonts/iconFonts/gameIcons.less index ea7b3aba5..a32ebdd08 100644 --- a/themes/fonts/iconFonts/gameIcons.less +++ b/themes/fonts/iconFonts/gameIcons.less @@ -8,19 +8,15 @@ .gi { /* use !important to prevent issues with browser extensions that change fonts */ - display : inline-block; - margin-right : 3px; + display : inline; font-family : 'Game-Icons' !important; line-height : 1; vertical-align : baseline; - -moz-osx-font-smoothing : grayscale; - -webkit-font-smoothing : antialiased; text-rendering : auto; /* Better Font Rendering =========== */ -webkit-font-smoothing : antialiased; -moz-osx-font-smoothing : grayscale; - &.zigzag-leaf::before { content : '\e900'; } &.zebra-shield::before { content : '\e901'; } From a87e42043734be81e4fc9656d465ea407c577c92 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Fri, 28 Jun 2024 22:46:56 -0400 Subject: [PATCH 30/45] Up version to 3.13.0 --- changelog.md | 39 +++++++++++++++++++++++++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 18c3205f7..0a9e509f2 100644 --- a/changelog.md +++ b/changelog.md @@ -84,6 +84,45 @@ pre { ## changelog For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery). +### Friday 28/6/2024 - v3.13.0 +{{taskList + +##### calculuschild + +* [x] Add `:emoji:` Markdown syntax, with autosuggest; start typing after the first `:` for matching emojis from +:fab_font_awesome: FontAwesome, :df_d20: DiceFont, :ei_action: ElderberryInn, and a subset of :gi_broadsword: GameIcons + +* [x] Fix `{curly injection}` to append to, rather than erase and replace target CSS +* [x] {{openSans **GET PDF**}} {{fa,fa-file-pdf}} now opens the print dialog directly, rather than redirecting to a separate page + +##### Gazook + +* [x] Several small style tweaks to the UI +* [x] Cleaning and refactoring several large pieces of code + +##### 5e-Cleric + +* [x] For error pages, add links to user account and `/share` page if available + +Fixes issue [#3298](https://github.com/naturalcrit/homebrewery/issues/3298) + +* [x] Change FrontCover title to use stroke outline instead of faking it with dozens of shadows +* [x] Cleaning and refactoring several large pieces of CSS + +##### abquintic + +* [x] Added additional {{openSans **TABLE OF CONTENTS**}} snippet options. Explicitly include or exclude items from the ToC generation via CSS properties +`--TOC:exclude` or `--TOC:include`, or change the included header depth from 3 to 6 (default 3) with `tocDepthH6` + +##### MurdoMaclachlan *(new contributor!)* + +* [x] Added "proficiency bonus" to Monster Stat Block snippet. + +Fixes issue [#3397](https://github.com/naturalcrit/homebrewery/issues/3397) +}} + +\column + ### Monday 18/3/2024 - v3.12.0 {{taskList diff --git a/package-lock.json b/package-lock.json index d9c862149..c7cdd1017 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebrewery", - "version": "3.12.0", + "version": "3.13.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "homebrewery", - "version": "3.12.0", + "version": "3.13.0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index b5b7824b3..83e180280 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "homebrewery", "description": "Create authentic looking D&D homebrews using only markdown", - "version": "3.12.0", + "version": "3.13.0", "engines": { "npm": "^10.2.x", "node": "^20.8.x" From 2cdd65b083aa67428b0cfa5b6c6d2bd98eafe9c6 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sat, 29 Jun 2024 11:29:31 -0400 Subject: [PATCH 31/45] revert DOMPURIFY for now --- client/homebrew/brewRenderer/brewRenderer.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/homebrew/brewRenderer/brewRenderer.jsx b/client/homebrew/brewRenderer/brewRenderer.jsx index 8168f9933..3c36244c1 100644 --- a/client/homebrew/brewRenderer/brewRenderer.jsx +++ b/client/homebrew/brewRenderer/brewRenderer.jsx @@ -37,7 +37,7 @@ const BrewPage = (props)=>{ index : 0, ...props }; - const cleanText = DOMPurify.sanitize(props.contents, purifyConfig); + const cleanText = props.contents; //DOMPurify.sanitize(props.contents, purifyConfig); return
; @@ -126,7 +126,7 @@ const BrewRenderer = (props)=>{ const renderStyle = ()=>{ if(!props.style) return; - const cleanStyle = DOMPurify.sanitize(props.style, purifyConfig); + const cleanStyle = props.style; //DOMPurify.sanitize(props.style, purifyConfig); //return
@layer styleTab {\n${sanitizeScriptTags(props.style)}\n} ` }} />; return
${cleanStyle} ` }} />; }; From 8ee70b092863e072eaddc1998e52fb21aa8fa987 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 1 Jul 2024 12:21:29 -0400 Subject: [PATCH 32/45] Only split curly attributes on on first =, allow ?, = in attributes --- shared/naturalcrit/markdown.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 95431487d..529129833 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -102,7 +102,7 @@ const mustacheSpans = { start(src) { return src.match(/{{[^{]/)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { const completeSpan = /^{{[^\n]*}}/; // Regex for the complete token - const inlineRegex = /{{(?=((?:[:=](?:"['\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1 *|}}/g; + const inlineRegex = /{{(?=((?:[:=](?:"['\w,\-()#%=?. ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1 *|}}/g; const match = completeSpan.exec(src); if(match) { //Find closing delimiter @@ -159,7 +159,7 @@ const mustacheDivs = { start(src) { return src.match(/\n *{{[^{]/m)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { const completeBlock = /^ *{{[^\n}]* *\n.*\n *}}/s; // Regex for the complete token - const blockRegex = /^ *{{(?=((?:[:=](?:"['\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1 *$|^ *}}$/gm; + const blockRegex = /^ *{{(?=((?:[:=](?:"['\w,\-()#%=?. ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1 *$|^ *}}$/gm; const match = completeBlock.exec(src); if(match) { //Find closing delimiter @@ -214,7 +214,7 @@ const mustacheInjectInline = { level : 'inline', start(src) { return src.match(/ *{[^{\n]/)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { - const inlineRegex = /^ *{(?=((?:[:=](?:"['\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1}/g; + const inlineRegex = /^ *{(?=((?:[:=](?:"['\w,\-()#%=?. ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1}/g; const match = inlineRegex.exec(src); if(match) { const lastToken = tokens[tokens.length - 1]; @@ -265,7 +265,7 @@ const mustacheInjectBlock = { level : 'block', start(src) { return src.match(/\n *{[^{\n]/m)?.index; }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { - const inlineRegex = /^ *{(?=((?:[:=](?:"['\w,\-()#%. ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1}/ym; + const inlineRegex = /^ *{(?=((?:[:=](?:"['\w,\-()#%=?. ]*"|[\w\-()#%.]*)|[^"=':{}\s]*)*))\1}/ym; const match = inlineRegex.exec(src); if(match) { const lastToken = tokens[tokens.length - 1]; @@ -771,7 +771,8 @@ const processStyleTags = (string)=>{ const attributes = _.remove(tags, (tag)=>(tag.includes('='))).map((tag)=>tag.replace(/="?([^"]*)"?/g, '="$1"')) ?.filter((attr)=>!attr.startsWith('class="') && !attr.startsWith('style="') && !attr.startsWith('id="')) .reduce((obj, attr)=>{ - let [key, value] = attr.split('='); + const index = attr.indexOf('='); + let [key, value] = [attr.substring(0, index), attr.substring(index + 1)]; value = value.replace(/"/g, ''); obj[key] = value; return obj; @@ -793,7 +794,8 @@ const extractHTMLStyleTags = (htmlString)=>{ const attributes = htmlString.match(/[a-zA-Z]+="[^"]*"/g) ?.filter((attr)=>!attr.startsWith('class="') && !attr.startsWith('style="') && !attr.startsWith('id="')) .reduce((obj, attr)=>{ - let [key, value] = attr.split('='); + const index = attr.indexOf('='); + let [key, value] = [attr.substring(0, index), attr.substring(index + 1)]; value = value.replace(/"/g, ''); obj[key] = value; return obj; From 2d570924d1489f35f7fad0253ee4eeb901bd07cf Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 1 Jul 2024 12:21:36 -0400 Subject: [PATCH 33/45] Add tests --- tests/markdown/mustache-syntax.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/markdown/mustache-syntax.test.js b/tests/markdown/mustache-syntax.test.js index b32876353..7b0115cae 100644 --- a/tests/markdown/mustache-syntax.test.js +++ b/tests/markdown/mustache-syntax.test.js @@ -338,6 +338,18 @@ describe('Injection: When an injection tag follows an element', ()=>{ const rendered = Markdown.render(source).trimReturns(); expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

homebrew mug

`); }); + + it('Renders an image with "=" in the url, and added attributes', function() { + const source = `![homebrew mug](https://i.imgur.com/hMna6G0.png?auth=12345&height=1024) {position:absolute,bottom:20px,left:130px,width:220px,a="b and c",d=e}`; + const rendered = Markdown.render(source).trimReturns(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

homebrew mug

`); + }); + + it('Renders an image and added attributes with "=" in the value, ', function() { + const source = `![homebrew mug](https://i.imgur.com/hMna6G0.png) {position:absolute,bottom:20px,left:130px,width:220px,a="b and c",d=e,otherUrl="url?auth=12345"}`; + const rendered = Markdown.render(source).trimReturns(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

homebrew mug

`); + }); }); describe('and that element is a block', ()=>{ From 7c60fbe6551e0bdac9832736588ae2dac40ff08a Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Tue, 2 Jul 2024 20:46:01 +1200 Subject: [PATCH 34/45] Remove page + 1 from ToC generator snippet --- themes/V3/5ePHB/snippets/tableOfContents.gen.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/V3/5ePHB/snippets/tableOfContents.gen.js b/themes/V3/5ePHB/snippets/tableOfContents.gen.js index 1ec778944..b212dea36 100644 --- a/themes/V3/5ePHB/snippets/tableOfContents.gen.js +++ b/themes/V3/5ePHB/snippets/tableOfContents.gen.js @@ -8,14 +8,14 @@ const getTOC = (pages)=>{ if(curDepth == targetDepth) { child.push({ title : title, - page : page + 1, + page : page, children : [] }); } else { if(child.length == 0) { child.push({ title : null, - page : page + 1, + page : page, children : [] }); } From d12f644f5bf83f306b5c76ac1cb2a896d77a6c8a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jul 2024 03:15:49 +0000 Subject: [PATCH 35/45] Bump react-router-dom from 6.23.1 to 6.24.1 Bumps [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom) from 6.23.1 to 6.24.1. - [Release notes](https://github.com/remix-run/react-router/releases) - [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router-dom/CHANGELOG.md) - [Commits](https://github.com/remix-run/react-router/commits/react-router-dom@6.24.1/packages/react-router-dom) --- updated-dependencies: - dependency-name: react-router-dom dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 26 +++++++++++++------------- package.json | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index c7cdd1017..057871ef4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,7 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-frame-component": "^4.1.3", - "react-router-dom": "6.23.1", + "react-router-dom": "6.24.1", "sanitize-filename": "1.6.3", "superagent": "^9.0.2", "vitreum": "git+https://git@github.com/calculuschild/vitreum.git" @@ -2864,9 +2864,9 @@ } }, "node_modules/@remix-run/router": { - "version": "1.16.1", - "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.16.1.tgz", - "integrity": "sha512-es2g3dq6Nb07iFxGk5GuHN20RwBZOsuDQN7izWIisUcv9r+d2C5jQxqmgkdebXgReWfiyUabcki6Fg77mSNrig==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.17.1.tgz", + "integrity": "sha512-mCOMec4BKd6BRGBZeSnGiIgwsbLGp3yhVqAD8H+PxiRNEHgDpZb8J1TnrSDlg97t0ySKMQJTHCWBCmBpSmkF6Q==", "engines": { "node": ">=14.0.0" } @@ -12090,11 +12090,11 @@ "dev": true }, "node_modules/react-router": { - "version": "6.23.1", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.23.1.tgz", - "integrity": "sha512-fzcOaRF69uvqbbM7OhvQyBTFDVrrGlsFdS3AL+1KfIBtGETibHzi3FkoTRyiDJnWNc2VxrfvR+657ROHjaNjqQ==", + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.24.1.tgz", + "integrity": "sha512-PTXFXGK2pyXpHzVo3rR9H7ip4lSPZZc0bHG5CARmj65fTT6qG7sTngmb6lcYu1gf3y/8KxORoy9yn59pGpCnpg==", "dependencies": { - "@remix-run/router": "1.16.1" + "@remix-run/router": "1.17.1" }, "engines": { "node": ">=14.0.0" @@ -12104,12 +12104,12 @@ } }, "node_modules/react-router-dom": { - "version": "6.23.1", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.23.1.tgz", - "integrity": "sha512-utP+K+aSTtEdbWpC+4gxhdlPFwuEfDKq8ZrPFU65bbRJY+l706qjR7yaidBpo3MSeA/fzwbXWbKBI6ftOnP3OQ==", + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.24.1.tgz", + "integrity": "sha512-U19KtXqooqw967Vw0Qcn5cOvrX5Ejo9ORmOtJMzYWtCT4/WOfFLIZGGsVLxcd9UkBO0mSTZtXqhZBsWlHr7+Sg==", "dependencies": { - "@remix-run/router": "1.16.1", - "react-router": "6.23.1" + "@remix-run/router": "1.17.1", + "react-router": "6.24.1" }, "engines": { "node": ">=14.0.0" diff --git a/package.json b/package.json index 83e180280..9bacb6c64 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "react": "^18.3.1", "react-dom": "^18.3.1", "react-frame-component": "^4.1.3", - "react-router-dom": "6.23.1", + "react-router-dom": "6.24.1", "sanitize-filename": "1.6.3", "superagent": "^9.0.2", "vitreum": "git+https://git@github.com/calculuschild/vitreum.git" From 086c4f74f6b153a226d87b8b091e3332b742645d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jul 2024 03:21:26 +0000 Subject: [PATCH 36/45] Bump marked-emoji from 1.4.0 to 1.4.1 Bumps [marked-emoji](https://github.com/UziTech/marked-emoji) from 1.4.0 to 1.4.1. - [Release notes](https://github.com/UziTech/marked-emoji/releases) - [Changelog](https://github.com/UziTech/marked-emoji/blob/main/release.config.cjs) - [Commits](https://github.com/UziTech/marked-emoji/compare/v1.4.0...v1.4.1) --- updated-dependencies: - dependency-name: marked-emoji dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 057871ef4..2e1f18c53 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "less": "^3.13.1", "lodash": "^4.17.21", "marked": "11.2.0", - "marked-emoji": "^1.4.0", + "marked-emoji": "^1.4.1", "marked-extended-tables": "^1.0.8", "marked-gfm-heading-id": "^3.1.3", "marked-smartypants-lite": "^1.0.2", @@ -10247,11 +10247,11 @@ } }, "node_modules/marked-emoji": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/marked-emoji/-/marked-emoji-1.4.0.tgz", - "integrity": "sha512-/2TJfGzXpiBBq+X3akHHbTrAjZPJDwR+7FV6SyQLECnQEfaoVkrpKZJzHhPTAq3Sl/A1l2frMT0u6b38VBBlNg==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/marked-emoji/-/marked-emoji-1.4.1.tgz", + "integrity": "sha512-3xHWQn8XD1LyhMpHxWpHTDWBZ9bpXLlW8JIqvyXTO6he7okKIB/W9fD/3fTg0DQuZlSQvPZ6Ub5hN6Rnmn7j9g==", "peerDependencies": { - "marked": ">=4 <13" + "marked": ">=4 <14" } }, "node_modules/marked-extended-tables": { diff --git a/package.json b/package.json index 9bacb6c64..3ce1297a6 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "less": "^3.13.1", "lodash": "^4.17.21", "marked": "11.2.0", - "marked-emoji": "^1.4.0", + "marked-emoji": "^1.4.1", "marked-extended-tables": "^1.0.8", "marked-gfm-heading-id": "^3.1.3", "marked-smartypants-lite": "^1.0.2", From e8e7237a8ecb6907d0dfcc804b8b31cdef856384 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Jul 2024 03:21:44 +0000 Subject: [PATCH 37/45] Bump marked-gfm-heading-id from 3.1.3 to 3.2.0 Bumps [marked-gfm-heading-id](https://github.com/markedjs/marked-gfm-heading-id) from 3.1.3 to 3.2.0. - [Release notes](https://github.com/markedjs/marked-gfm-heading-id/releases) - [Changelog](https://github.com/markedjs/marked-gfm-heading-id/blob/main/release.config.cjs) - [Commits](https://github.com/markedjs/marked-gfm-heading-id/compare/v3.1.3...v3.2.0) --- updated-dependencies: - dependency-name: marked-gfm-heading-id dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 057871ef4..654e88dae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,7 @@ "marked": "11.2.0", "marked-emoji": "^1.4.0", "marked-extended-tables": "^1.0.8", - "marked-gfm-heading-id": "^3.1.3", + "marked-gfm-heading-id": "^3.2.0", "marked-smartypants-lite": "^1.0.2", "markedLegacy": "npm:marked@^0.3.19", "moment": "^2.30.1", @@ -10263,9 +10263,9 @@ } }, "node_modules/marked-gfm-heading-id": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/marked-gfm-heading-id/-/marked-gfm-heading-id-3.1.3.tgz", - "integrity": "sha512-A0cRU4PCueX/5m8VE4mT8uTQ36l3xMYRojz3Eqnk4BmUFZ0T+9Xhn2KvHcANP4qbhfOeuMrWJCTQbASIBR5xeg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/marked-gfm-heading-id/-/marked-gfm-heading-id-3.2.0.tgz", + "integrity": "sha512-Xfxpr5lXLDLY10XqzSCA9l2dDaiabQUgtYM9hw8yunyVsB/xYBRpiic6BOiY/EAJw1ik1eWr1ET1HKOAPZBhXg==", "dependencies": { "github-slugger": "^2.0.0" }, diff --git a/package.json b/package.json index 9bacb6c64..419f54aa4 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "marked": "11.2.0", "marked-emoji": "^1.4.0", "marked-extended-tables": "^1.0.8", - "marked-gfm-heading-id": "^3.1.3", + "marked-gfm-heading-id": "^3.2.0", "marked-smartypants-lite": "^1.0.2", "markedLegacy": "npm:marked@^0.3.19", "moment": "^2.30.1", From 80e039b194b72b5e7bb97791c613e9f1b0232474 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 18:41:01 +0000 Subject: [PATCH 38/45] Bump mongoose from 8.4.1 to 8.4.5 Bumps [mongoose](https://github.com/Automattic/mongoose) from 8.4.1 to 8.4.5. - [Release notes](https://github.com/Automattic/mongoose/releases) - [Changelog](https://github.com/Automattic/mongoose/blob/master/CHANGELOG.md) - [Commits](https://github.com/Automattic/mongoose/compare/8.4.1...8.4.5) --- updated-dependencies: - dependency-name: mongoose dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index ca19b6367..bc4ce6b7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,7 +38,7 @@ "marked-smartypants-lite": "^1.0.2", "markedLegacy": "npm:marked@^0.3.19", "moment": "^2.30.1", - "mongoose": "^8.4.1", + "mongoose": "^8.4.5", "nanoid": "3.3.4", "nconf": "^0.12.1", "react": "^18.3.1", @@ -10656,9 +10656,9 @@ } }, "node_modules/mongoose": { - "version": "8.4.1", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.4.1.tgz", - "integrity": "sha512-odQ2WEWGL3hb0Qex+QMN4eH6D34WdMEw7F1If2MGABApSDmG9cMmqv/G1H6WsXmuaH9mkuuadW/WbLE5+tHJwA==", + "version": "8.4.5", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.4.5.tgz", + "integrity": "sha512-E5KjBThxST2uFSKKXuiMa9H9Zx4DLTSLuxodAnIzJRixNwc1ARTlJUK1m0a80EB+ZKGP4QNTasyUYRG9DUSHOA==", "dependencies": { "bson": "^6.7.0", "kareem": "2.6.3", diff --git a/package.json b/package.json index 1177687ca..3cd326541 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,7 @@ "marked-smartypants-lite": "^1.0.2", "markedLegacy": "npm:marked@^0.3.19", "moment": "^2.30.1", - "mongoose": "^8.4.1", + "mongoose": "^8.4.5", "nanoid": "3.3.4", "nconf": "^0.12.1", "react": "^18.3.1", From e07a04ebfa63113eb9bd48dc36d4ac4e61e19ce3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 18:53:33 +0000 Subject: [PATCH 39/45] Bump ws from 7.5.9 to 7.5.10 Bumps [ws](https://github.com/websockets/ws) from 7.5.9 to 7.5.10. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/7.5.9...7.5.10) --- updated-dependencies: - dependency-name: ws dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index bc4ce6b7d..4f7ab47a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15180,9 +15180,9 @@ } }, "node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "engines": { "node": ">=8.3.0" }, From 450baee66a264674d314116ae15118da98be86c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 18:55:32 +0000 Subject: [PATCH 40/45] Bump eslint-plugin-react from 7.34.2 to 7.34.3 Bumps [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) from 7.34.2 to 7.34.3. - [Release notes](https://github.com/jsx-eslint/eslint-plugin-react/releases) - [Changelog](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/CHANGELOG.md) - [Commits](https://github.com/jsx-eslint/eslint-plugin-react/compare/v7.34.2...v7.34.3) --- updated-dependencies: - dependency-name: eslint-plugin-react dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package-lock.json | 25 ++++++++++++++----------- package.json | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4f7ab47a7..8e183184b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,7 +52,7 @@ "devDependencies": { "eslint": "^8.57.0", "eslint-plugin-jest": "^28.6.0", - "eslint-plugin-react": "^7.34.2", + "eslint-plugin-react": "^7.34.3", "jest": "^29.7.0", "jest-expect-message": "^1.1.3", "postcss-less": "^6.0.0", @@ -3507,16 +3507,19 @@ } }, "node_modules/array.prototype.tosorted": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/array.prototype.tosorted/-/array.prototype.tosorted-1.1.3.tgz", - "integrity": "sha512-/DdH4TiTmOKzyQbp/eadcCVexiCb36xJg7HshYOYJnNZFDj33GEv0P7GxsynpShhq4OLYJzbGcBDkLsDt7MnNg==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/array.prototype.tosorted/-/array.prototype.tosorted-1.1.4.tgz", + "integrity": "sha512-p6Fx8B7b7ZhL/gmUsAy0D15WhvDccw3mnGNbZpi3pmeJdxtWsj2jEaI4Y6oo3XiHfzuSgPwKc04MYt6KgvC/wA==", "dev": true, "dependencies": { - "call-bind": "^1.0.5", + "call-bind": "^1.0.7", "define-properties": "^1.2.1", - "es-abstract": "^1.22.3", - "es-errors": "^1.1.0", + "es-abstract": "^1.23.3", + "es-errors": "^1.3.0", "es-shim-unscopables": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" } }, "node_modules/arraybuffer.prototype.slice": { @@ -5848,16 +5851,16 @@ } }, "node_modules/eslint-plugin-react": { - "version": "7.34.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.34.2.tgz", - "integrity": "sha512-2HCmrU+/JNigDN6tg55cRDKCQWicYAPB38JGSFDQt95jDm8rrvSUo7YPkOIm5l6ts1j1zCvysNcasvfTMQzUOw==", + "version": "7.34.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.34.3.tgz", + "integrity": "sha512-aoW4MV891jkUulwDApQbPYTVZmeuSyFrudpbTAQuj5Fv8VL+o6df2xIGpw8B0hPjAaih1/Fb0om9grCdyFYemA==", "dev": true, "dependencies": { "array-includes": "^3.1.8", "array.prototype.findlast": "^1.2.5", "array.prototype.flatmap": "^1.3.2", "array.prototype.toreversed": "^1.1.2", - "array.prototype.tosorted": "^1.1.3", + "array.prototype.tosorted": "^1.1.4", "doctrine": "^2.1.0", "es-iterator-helpers": "^1.0.19", "estraverse": "^5.3.0", diff --git a/package.json b/package.json index 3cd326541..8f2c1da06 100644 --- a/package.json +++ b/package.json @@ -124,7 +124,7 @@ "devDependencies": { "eslint": "^8.57.0", "eslint-plugin-jest": "^28.6.0", - "eslint-plugin-react": "^7.34.2", + "eslint-plugin-react": "^7.34.3", "jest": "^29.7.0", "jest-expect-message": "^1.1.3", "postcss-less": "^6.0.0", From 1564bc744840988712d762ae1fa579ada59a500e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 18:59:10 +0000 Subject: [PATCH 41/45] Bump @googleapis/drive from 8.10.0 to 8.11.0 Bumps [@googleapis/drive](https://github.com/googleapis/google-api-nodejs-client) from 8.10.0 to 8.11.0. - [Release notes](https://github.com/googleapis/google-api-nodejs-client/releases) - [Changelog](https://github.com/googleapis/google-api-nodejs-client/blob/main/release-please-config.json) - [Commits](https://github.com/googleapis/google-api-nodejs-client/compare/drive-v8.10.0...drive-v8.11.0) --- updated-dependencies: - dependency-name: "@googleapis/drive" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8e183184b..e3a3f355d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@babel/plugin-transform-runtime": "^7.24.7", "@babel/preset-env": "^7.24.7", "@babel/preset-react": "^7.24.7", - "@googleapis/drive": "^8.10.0", + "@googleapis/drive": "^8.11.0", "body-parser": "^1.20.2", "classnames": "^2.5.1", "codemirror": "^5.65.6", @@ -1993,9 +1993,9 @@ } }, "node_modules/@googleapis/drive": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/@googleapis/drive/-/drive-8.10.0.tgz", - "integrity": "sha512-loumtaDmAn2JvU4KuFMhhtaYG1Hxw0RVS4vl+rOWMU7NAU151XYfIWFDJfFFZjvYZxH4tbsmHEnF+DKH1hQ75Q==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/@googleapis/drive/-/drive-8.11.0.tgz", + "integrity": "sha512-HW6/2oThc4X086mGkZxpdP4P+aHpYbjHa6wr9l1F/R+snpk6G8/EuRXEcTkgQUl2t/NdNz3lj8re0AQBG5faSA==", "dependencies": { "googleapis-common": "^7.0.0" }, diff --git a/package.json b/package.json index 8f2c1da06..4a42c528c 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@babel/plugin-transform-runtime": "^7.24.7", "@babel/preset-env": "^7.24.7", "@babel/preset-react": "^7.24.7", - "@googleapis/drive": "^8.10.0", + "@googleapis/drive": "^8.11.0", "body-parser": "^1.20.2", "classnames": "^2.5.1", "codemirror": "^5.65.6", From 9c4de58161879b4c4d26fc6cc513f7aabf2892e5 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Sat, 6 Jul 2024 13:22:47 +1200 Subject: [PATCH 42/45] Limit htmlString to the first element ONLY --- shared/naturalcrit/markdown.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 529129833..cabb73c89 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -788,10 +788,11 @@ const processStyleTags = (string)=>{ }; const extractHTMLStyleTags = (htmlString)=>{ - const id = htmlString.match(/id="([^"]*)"/)?.[1] || null; - const classes = htmlString.match(/class="([^"]*)"/)?.[1] || null; - const styles = htmlString.match(/style="([^"]*)"/)?.[1] || null; - const attributes = htmlString.match(/[a-zA-Z]+="[^"]*"/g) + const firstElementOnly = htmlString.indexOf('>') > 0 ? htmlString.substring(0, htmlString.indexOf('>')) : htmlString; + const id = firstElementOnly.match(/id="([^"]*)"/)?.[1] || null; + const classes = firstElementOnly.match(/class="([^"]*)"/)?.[1] || null; + const styles = firstElementOnly.match(/style="([^"]*)"/)?.[1] || null; + const attributes = firstElementOnly.match(/[a-zA-Z]+="[^"]*"/g) ?.filter((attr)=>!attr.startsWith('class="') && !attr.startsWith('style="') && !attr.startsWith('id="')) .reduce((obj, attr)=>{ const index = attr.indexOf('='); From 5433cda52fb1493ea25139a363e5714d4dca8a4c Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sat, 6 Jul 2024 17:05:23 -0400 Subject: [PATCH 43/45] Add test case --- tests/markdown/mustache-syntax.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/markdown/mustache-syntax.test.js b/tests/markdown/mustache-syntax.test.js index 7b0115cae..3f7f2529b 100644 --- a/tests/markdown/mustache-syntax.test.js +++ b/tests/markdown/mustache-syntax.test.js @@ -333,6 +333,13 @@ describe('Injection: When an injection tag follows an element', ()=>{ expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('

text{background:blue}

'); }); + it('Renders an parent and child element, each modified by an injector', function() { + const source = dedent`**bolded text**{color:red} + {color:blue}`; + const rendered = Markdown.render(source).trimReturns(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('

bolded text

'); + }); + it('Renders an image with added attributes', function() { const source = `![homebrew mug](https://i.imgur.com/hMna6G0.png) {position:absolute,bottom:20px,left:130px,width:220px,a="b and c",d=e}`; const rendered = Markdown.render(source).trimReturns(); From 0a199e750fa6c445e126f00ed491d6fa6e75febe Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sat, 6 Jul 2024 18:00:18 -0400 Subject: [PATCH 44/45] Simplify string splitting code String.split will return the substring before > or the whole string if no > exists. --- shared/naturalcrit/markdown.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index cabb73c89..39939f306 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -787,8 +787,9 @@ const processStyleTags = (string)=>{ }; }; +//Given a string representing an HTML element, extract all of its properties (id, class, style, and other attributes) const extractHTMLStyleTags = (htmlString)=>{ - const firstElementOnly = htmlString.indexOf('>') > 0 ? htmlString.substring(0, htmlString.indexOf('>')) : htmlString; + const firstElementOnly = htmlString.split('>')[0]; const id = firstElementOnly.match(/id="([^"]*)"/)?.[1] || null; const classes = firstElementOnly.match(/class="([^"]*)"/)?.[1] || null; const styles = firstElementOnly.match(/style="([^"]*)"/)?.[1] || null; From f8841c068f4971a44b0f943505ad331c12d1d3b9 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Sat, 6 Jul 2024 18:20:11 -0400 Subject: [PATCH 45/45] Up Version to 3.13.1 --- changelog.md | 10 ++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 0a9e509f2..b331fc4f0 100644 --- a/changelog.md +++ b/changelog.md @@ -84,6 +84,16 @@ pre { ## changelog For a full record of development, visit our [Github Page](https://github.com/naturalcrit/homebrewery). +### Saturday 6/7/2024 - v3.13.1 +{{taskList + +##### calculuschild, G-Ambatte + +* [x] Hotfixes for issues with v3.13.0 + +Fixes issues [#3559](https://github.com/naturalcrit/homebrewery/issues/3559), [#3552](https://github.com/naturalcrit/homebrewery/issues/3552), [#3554](https://github.com/naturalcrit/homebrewery/issues/3554) +}} + ### Friday 28/6/2024 - v3.13.0 {{taskList diff --git a/package-lock.json b/package-lock.json index e3a3f355d..cce4d5577 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebrewery", - "version": "3.13.0", + "version": "3.13.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "homebrewery", - "version": "3.13.0", + "version": "3.13.1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 4a42c528c..321f9afbe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "homebrewery", "description": "Create authentic looking D&D homebrews using only markdown", - "version": "3.13.0", + "version": "3.13.1", "engines": { "npm": "^10.2.x", "node": "^20.8.x"