mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-04 14:42:40 +00:00
Shift Footer generation to snippet
This commit is contained in:
@@ -8,6 +8,7 @@ const ClassFeatureGen = require('./snippets/classfeature.gen.js');
|
||||
const CoverPageGen = require('./snippets/coverpage.gen.js');
|
||||
const TableOfContentsGen = require('./snippets/tableOfContents.gen.js');
|
||||
const indexGen = require('./snippets/index.gen.js');
|
||||
const FooterGen = require('./snippets/footer.gen.js');
|
||||
const dedent = require('dedent-tabs').default;
|
||||
|
||||
|
||||
@@ -29,6 +30,11 @@ module.exports = [
|
||||
icon : 'fas fa-sort-numeric-down',
|
||||
gen : '{{pageNumber,auto}}\n{{footnote PART 1 | SECTION NAME}}\n\n'
|
||||
},
|
||||
{
|
||||
name : 'Footer',
|
||||
icon : 'fas fa-sort-numeric-down',
|
||||
gen : FooterGen
|
||||
},
|
||||
{
|
||||
name : 'Table of Contents',
|
||||
icon : 'fas fa-book',
|
||||
|
||||
16
themes/V3/5ePHB/snippets/footer.gen.js
Normal file
16
themes/V3/5ePHB/snippets/footer.gen.js
Normal file
@@ -0,0 +1,16 @@
|
||||
module.exports = function(brew, params){
|
||||
const cursorPos = params.cursorPos;
|
||||
const headerSize = params.headerSize || 1;
|
||||
|
||||
let header='';
|
||||
while (header.length < headerSize) {
|
||||
header = header.concat('#');
|
||||
}
|
||||
header = header.concat(' ');
|
||||
|
||||
const textArray = brew.text.split('\n').slice(0, cursorPos.line).reverse();
|
||||
const textArrayFilter = textArray.filter((line)=>{ return line.slice(0, header.length) == header; });
|
||||
const text = textArrayFilter[0]?.slice(header.length) || 'PART 1 | SECTION NAME';
|
||||
|
||||
return `\n{{footnote ${text}}}\n`;
|
||||
};
|
||||
Reference in New Issue
Block a user