mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-09 22:22:41 +00:00
Relocate more general purposes snippets from 5ePHB to Blank
Should include all supporting style content.
This commit is contained in:
@@ -4,6 +4,8 @@ const WatercolorGen = require('./snippets/watercolor.gen.js');
|
||||
const ImageMaskGen = require('./snippets/imageMask.gen.js');
|
||||
const FooterGen = require('./snippets/footer.gen.js');
|
||||
const dedent = require('dedent-tabs').default;
|
||||
const TableOfContentsGen = require('./snippets/tableOfContents.gen.js');
|
||||
const indexGen = require('./snippets/index.gen.js');
|
||||
|
||||
module.exports = [
|
||||
|
||||
@@ -125,7 +127,53 @@ module.exports = [
|
||||
[Homebrewery.Naturalcrit.com](https://homebrewery.naturalcrit.com)
|
||||
}}\n\n`;
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
name : 'Table of Contents',
|
||||
icon : 'fas fa-book',
|
||||
gen : TableOfContentsGen,
|
||||
experimental : true,
|
||||
subsnippets : [
|
||||
{
|
||||
name : 'Table of Contents',
|
||||
icon : 'fas fa-book',
|
||||
gen : TableOfContentsGen,
|
||||
experimental : true
|
||||
},
|
||||
{
|
||||
name : 'Include in ToC up to H3',
|
||||
icon : 'fas fa-dice-three',
|
||||
gen : dedent `\n{{tocDepthH3
|
||||
}}\n`,
|
||||
|
||||
},
|
||||
{
|
||||
name : 'Include in ToC up to H4',
|
||||
icon : 'fas fa-dice-four',
|
||||
gen : dedent `\n{{tocDepthH4
|
||||
}}\n`,
|
||||
},
|
||||
{
|
||||
name : 'Include in ToC up to H5',
|
||||
icon : 'fas fa-dice-five',
|
||||
gen : dedent `\n{{tocDepthH5
|
||||
}}\n`,
|
||||
},
|
||||
{
|
||||
name : 'Include in ToC up to H6',
|
||||
icon : 'fas fa-dice-six',
|
||||
gen : dedent `\n{{tocDepthH6
|
||||
}}\n`,
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name : 'Index',
|
||||
icon : 'fas fa-bars',
|
||||
gen : indexGen,
|
||||
experimental : true
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -138,6 +186,29 @@ module.exports = [
|
||||
icon : 'fas fa-code',
|
||||
gen : '/* This is a comment that will not be rendered into your brew. */'
|
||||
},
|
||||
{
|
||||
name : 'Remove Drop Cap',
|
||||
icon : 'fas fa-remove-format',
|
||||
gen : dedent`/* Removes Drop Caps */
|
||||
.page h1+p:first-letter {
|
||||
all: unset;
|
||||
}\n\n
|
||||
/* Removes Small-Caps in first line */
|
||||
.page h1+p:first-line {
|
||||
all: unset;
|
||||
}`
|
||||
},
|
||||
{
|
||||
name : 'Tweak Drop Cap',
|
||||
icon : 'fas fa-sliders-h',
|
||||
gen : dedent`/* Drop Cap settings */
|
||||
.page h1 + p::first-letter {
|
||||
font-family: SolberaImitationRemake;
|
||||
font-size: 3.5cm;
|
||||
background-image: linear-gradient(-45deg, #322814, #998250, #322814);
|
||||
line-height: 1em;
|
||||
}\n\n`
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
85
themes/V3/Blank/snippets/index.gen.js
Normal file
85
themes/V3/Blank/snippets/index.gen.js
Normal file
@@ -0,0 +1,85 @@
|
||||
const dedent = require('dedent-tabs').default;
|
||||
|
||||
module.exports = ()=>{
|
||||
return dedent`
|
||||
{{index,wide,columns:5;
|
||||
##### Index
|
||||
- Ankhesh-Bort
|
||||
- city map, 7
|
||||
- city watch, 12
|
||||
- guilds, 19
|
||||
- Cheese
|
||||
- types of cheese, 8
|
||||
- cheese-related magic, 14
|
||||
- cheese-related quests, 26-27
|
||||
- Death
|
||||
- appearance, 10
|
||||
- personality, 13
|
||||
- hobbies, 23
|
||||
- Elves
|
||||
- types of elves, 15
|
||||
- elvish magic, 24
|
||||
- elvish curses, 28
|
||||
- Footnotes
|
||||
- types of footnotes, 16-17
|
||||
- footnote rules, 20-21
|
||||
- footnote humor, 29-30
|
||||
- Gods
|
||||
- types of gods, 12
|
||||
- godly interventions, 25
|
||||
- godly conflicts, 31
|
||||
- Heroes
|
||||
- class features, 11-12
|
||||
- heroic deeds, 26-27
|
||||
- Inns
|
||||
- types of inns, 9
|
||||
- inn amenities, 18
|
||||
- Jokes
|
||||
- types of jokes, 11-12
|
||||
- joke delivery, 25
|
||||
- Knives
|
||||
- types of knives, 16-17
|
||||
- knife skills, 22-23
|
||||
- knife fights, 28-29
|
||||
- Luggage
|
||||
- appearance, 10
|
||||
- personality, 13
|
||||
- abilities, 23
|
||||
- Magic
|
||||
- types of magic, 15
|
||||
- magic rules, 24
|
||||
- magic mishaps, 28
|
||||
- Socks
|
||||
- types of socks, 9
|
||||
- sock-related magic (yes, really), 15
|
||||
- sock-related quests (no, really), 26
|
||||
- Trolls
|
||||
- appearance and biology, 11
|
||||
- culture and language, 18
|
||||
- troll rights and activism, 31
|
||||
- Unknown University
|
||||
- history and architecture, 12
|
||||
- faculty and staff, 20
|
||||
- courses and exams, 33
|
||||
- Vampires
|
||||
- types and origins, 13
|
||||
- vampiric powers and weaknesses, 21
|
||||
- vampiric etiquette and politics, 34
|
||||
- Witches
|
||||
- types and traditions, 14
|
||||
- witchcraft and headology, 22
|
||||
- witch trials and tribulations, 35
|
||||
- Xylophones
|
||||
- musical instruments or weapons?, 15
|
||||
- xylophone-related magic and lore, 23
|
||||
- xylophone-related quests and puzzles, 36
|
||||
- Yetis
|
||||
- appearance and behavior, 16
|
||||
- yeti philosophy and religion, 24
|
||||
- yeti encounters and stories, 37
|
||||
- Zombies
|
||||
- types and causes, 17
|
||||
- zombie rights and duties, 25
|
||||
- zombie survival and prevention, 38
|
||||
}}`;
|
||||
};
|
||||
77
themes/V3/Blank/snippets/tableOfContents.gen.js
Normal file
77
themes/V3/Blank/snippets/tableOfContents.gen.js
Normal file
@@ -0,0 +1,77 @@
|
||||
const _ = require('lodash');
|
||||
const dedent = require('dedent-tabs').default;
|
||||
|
||||
const getTOC = (pages)=>{
|
||||
|
||||
const recursiveAdd = (title, page, targetDepth, child, curDepth=0)=>{
|
||||
if(curDepth > 5) return; // Something went wrong.
|
||||
if(curDepth == targetDepth) {
|
||||
child.push({
|
||||
title : title,
|
||||
page : page,
|
||||
children : []
|
||||
});
|
||||
} else {
|
||||
if(child.length == 0) {
|
||||
child.push({
|
||||
title : null,
|
||||
page : page,
|
||||
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');
|
||||
const headerDepth = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6'];
|
||||
|
||||
_.each(headings, (heading)=>{
|
||||
const onPage = parseInt(heading.closest('.page').id?.replace(/^p/, ''));
|
||||
const ToCExclude = getComputedStyle(heading).getPropertyValue('--TOC');
|
||||
|
||||
if(ToCExclude != 'exclude') {
|
||||
recursiveAdd(heading.textContent.trim(), onPage, headerDepth.indexOf(heading.tagName), res);
|
||||
}
|
||||
});
|
||||
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, entry.title == null ? curDepth : curDepth+1);
|
||||
if(children.length) {
|
||||
toc.push(...children);
|
||||
}
|
||||
});
|
||||
}
|
||||
return toc;
|
||||
};
|
||||
|
||||
module.exports = function(props){
|
||||
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;
|
||||
}, []).join('\n');
|
||||
|
||||
return dedent`
|
||||
{{toc,wide
|
||||
# Contents
|
||||
|
||||
${markdown}
|
||||
}}
|
||||
\n`;
|
||||
};
|
||||
@@ -482,3 +482,130 @@ body { counter-reset : page-numbers; }
|
||||
.pageNumber { left : 30px; }
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************
|
||||
// * INDEX
|
||||
// *****************************/
|
||||
.page {
|
||||
.index {
|
||||
font-size : 0.218cm;
|
||||
|
||||
ul ul { margin : 0; }
|
||||
|
||||
ul {
|
||||
padding-left : 0;
|
||||
text-indent : 0;
|
||||
list-style-type : none;
|
||||
}
|
||||
|
||||
& > ul > li {
|
||||
padding-left : 1.5em;
|
||||
text-indent : -1.5em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************
|
||||
// * TABLE OF CONTENTS
|
||||
// *****************************/
|
||||
|
||||
// Default Exclusions
|
||||
// Anything not exlcuded is included, default Headers are H1, H2, and H3.
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
.page:has(.frontCover),
|
||||
.page:has(.backCover),
|
||||
.page:has(.insideCover),
|
||||
.monster,
|
||||
.noToC,
|
||||
.toc { --TOC: exclude; }
|
||||
|
||||
.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; }
|
||||
|
||||
.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(.partCover) {
|
||||
--TOC: exclude;
|
||||
& h1 {
|
||||
--TOC: include;
|
||||
}
|
||||
}
|
||||
|
||||
.page {
|
||||
&:has(.toc)::after { display : none; }
|
||||
.toc {
|
||||
-webkit-column-break-inside : avoid;
|
||||
page-break-inside : avoid;
|
||||
break-inside : avoid;
|
||||
h1 {
|
||||
margin-bottom : 0.3cm;
|
||||
text-align : center;
|
||||
}
|
||||
a {
|
||||
display : inline;
|
||||
color : inherit;
|
||||
text-decoration : none;
|
||||
&:hover { text-decoration : underline; }
|
||||
}
|
||||
h4 {
|
||||
margin-top : 0.2cm;
|
||||
line-height : 0.4cm;
|
||||
& + ul li { line-height : 1.2em; }
|
||||
}
|
||||
ul {
|
||||
padding-left : 0;
|
||||
margin-top : 0;
|
||||
list-style-type : none;
|
||||
a {
|
||||
display : flex;
|
||||
flex-flow : row nowrap;
|
||||
justify-content : space-between;
|
||||
width : 100%;
|
||||
}
|
||||
li + li h3 {
|
||||
margin-top : 0.26cm;
|
||||
line-height : 1em;
|
||||
}
|
||||
h3 span:first-child::after { border : none; }
|
||||
span {
|
||||
display : contents;
|
||||
&:first-child::after {
|
||||
bottom : 0.08cm;
|
||||
flex : 1;
|
||||
margin-right : 0.16cm;
|
||||
margin-bottom : 0.08cm;
|
||||
margin-left : 0.08cm; /* Spacing before dot leaders */
|
||||
content : '';
|
||||
border-bottom : 0.05cm dotted #000000;
|
||||
}
|
||||
&:last-child {
|
||||
display : inline-block;
|
||||
align-self : flex-end;
|
||||
font-family : 'BookInsanityRemake';
|
||||
font-size : 0.34cm;
|
||||
font-weight : normal;
|
||||
color : #000000;
|
||||
}
|
||||
}
|
||||
ul { /* List indent */
|
||||
margin-left : 1em;
|
||||
}
|
||||
}
|
||||
&.wide {
|
||||
.useColumns(0.96, @fillMode: balance);
|
||||
}
|
||||
}
|
||||
.toc.wide li {
|
||||
break-inside: auto;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user