mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-10 09:12:39 +00:00
Relocate more general purposes snippets from 5ePHB to Blank
Should include all supporting style content.
This commit is contained in:
@@ -1,85 +0,0 @@
|
||||
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
|
||||
}}`;
|
||||
};
|
||||
@@ -1,77 +0,0 @@
|
||||
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`;
|
||||
};
|
||||
Reference in New Issue
Block a user