mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 18:32:40 +00:00
Merge branch 'master' into marked-definition-lists
This commit is contained in:
@@ -8,6 +8,8 @@ import { markedSmartypantsLite as MarkedSmartypantsLite }
|
||||
import { gfmHeadingId as MarkedGFMHeadingId, resetHeadings as MarkedGFMResetHeadingIDs } from 'marked-gfm-heading-id';
|
||||
import { markedEmoji as MarkedEmojis } from 'marked-emoji';
|
||||
import MarkedDefinitionLists from 'marked-definition-lists';
|
||||
import MarkedAlignedParagraphs from 'marked-alignment-paragraphs';
|
||||
import MarkedNonbreakingSpaces from 'marked-nonbreaking-spaces';
|
||||
import MarkedSubSuperText from 'marked-subsuper-text';
|
||||
import { romanize } from 'romans';
|
||||
import writtenNumber from 'written-number';
|
||||
@@ -388,42 +390,6 @@ const mustacheInjectBlock = {
|
||||
}
|
||||
};
|
||||
|
||||
const justifiedParagraphClasses = [];
|
||||
justifiedParagraphClasses[2] = 'Left';
|
||||
justifiedParagraphClasses[4] = 'Right';
|
||||
justifiedParagraphClasses[6] = 'Center';
|
||||
|
||||
const justifiedParagraphs = {
|
||||
name : 'justifiedParagraphs',
|
||||
level : 'block',
|
||||
start(src) {
|
||||
return src.match(/\n(?:-:|:-|-:) {1}/m)?.index;
|
||||
}, // Hint to Marked.js to stop and check for a match
|
||||
tokenizer(src, tokens) {
|
||||
const regex = /^(((:-))|((-:))|((:-:))) .+(\n(([^\n].*\n)*(\n|$))|$)/ygm;
|
||||
const match = regex.exec(src);
|
||||
if(match?.length) {
|
||||
let whichJustify;
|
||||
if(match[2]?.length) whichJustify = 2;
|
||||
if(match[4]?.length) whichJustify = 4;
|
||||
if(match[6]?.length) whichJustify = 6;
|
||||
return {
|
||||
type : 'justifiedParagraphs', // Should match "name" above
|
||||
raw : match[0], // Text to consume from the source
|
||||
length : match[whichJustify].length,
|
||||
text : match[0].slice(match[whichJustify].length),
|
||||
class : justifiedParagraphClasses[whichJustify],
|
||||
tokens : this.lexer.inlineTokens(match[0].slice(match[whichJustify].length + 1))
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer(token) {
|
||||
return `<p align="${token.class}">${this.parser.parseInline(token.tokens)}</p>`;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
const forcedParagraphBreaks = {
|
||||
name : 'hardBreaks',
|
||||
level : 'block',
|
||||
@@ -445,27 +411,6 @@ const forcedParagraphBreaks = {
|
||||
}
|
||||
};
|
||||
|
||||
const nonbreakingSpaces = {
|
||||
name : 'nonbreakingSpaces',
|
||||
level : 'inline',
|
||||
start(src) { return src.match(/:>+/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
||||
tokenizer(src, tokens) {
|
||||
const regex = /:(>+)/ym;
|
||||
const match = regex.exec(src);
|
||||
if(match?.length) {
|
||||
return {
|
||||
type : 'nonbreakingSpaces', // Should match "name" above
|
||||
raw : match[0], // Text to consume from the source
|
||||
length : match[1].length,
|
||||
text : ''
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer(token) {
|
||||
return ` `.repeat(token.length).concat('');
|
||||
}
|
||||
};
|
||||
|
||||
//v=====--------------------< Variable Handling >-------------------=====v// 242 lines
|
||||
const replaceVar = function(input, hoist=false, allowUnresolved=false) {
|
||||
const regex = /([!$]?)\[((?!\s*\])(?:\\.|[^\[\]\\])+)\]/g;
|
||||
@@ -738,7 +683,9 @@ Marked.use(MarkedDefinitionLists());
|
||||
Marked.use({ extensions : [justifiedParagraphs, forcedParagraphBreaks,
|
||||
nonbreakingSpaces, mustacheSpans, mustacheDivs, mustacheInjectInline] });
|
||||
Marked.use(mustacheInjectBlock);
|
||||
Marked.use(MarkedAlignedParagraphs());
|
||||
Marked.use(MarkedSubSuperText());
|
||||
Marked.use(MarkedNonbreakingSpaces());
|
||||
Marked.use({ renderer: renderer, tokenizer: tokenizer, mangle: false });
|
||||
Marked.use(MarkedExtendedTables({ interruptPatterns: tableTerminators }), MarkedGFMHeadingId({ globalSlugs: true }),
|
||||
MarkedSmartypantsLite(), MarkedEmojis(MarkedEmojiOptions));
|
||||
|
||||
Reference in New Issue
Block a user