0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-20 05:22:47 +00:00

Add Styles for Forced Justifcation Tokens

This commit is contained in:
David Bolack
2024-11-22 20:45:58 -06:00
parent 440ad516df
commit deb9c6651f
10 changed files with 1133 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
import Markdown from '../../../../shared/naturalcrit/markdown.js';
module.exports = {
createFooterFunc : function(headerSize=1){
return (props)=>{
const cursorPos = props.cursorPos;
const markdownText = props.brew.text.split('\n').slice(0, cursorPos.line).join('\n');
const markdownTokens = Markdown.marked.lexer(markdownText);
const headerToken = markdownTokens.findLast((lexerToken)=>{ return lexerToken.type === 'heading' && lexerToken.depth === headerSize; });
const headerText = headerToken?.tokens.map((token)=>{ return token.text; }).join('');
const outputText = headerText || 'PART 1 | SECTION NAME';
return `\n{{footnote ${outputText}}}\n`;
};
}
};