mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 01:22:44 +00:00
Merge branch 'master' into Issue_1488
This commit is contained in:
@@ -205,6 +205,34 @@ const mustacheInjectBlock = {
|
||||
}
|
||||
};
|
||||
|
||||
const superSubScripts = {
|
||||
name : 'superSubScript',
|
||||
level : 'inline',
|
||||
start(src) { return src.match(/\^/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
||||
tokenizer(src, tokens) {
|
||||
const superRegex = /^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^/m;
|
||||
const subRegex = /^\^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^\^/m;
|
||||
let isSuper = false;
|
||||
let match = subRegex.exec(src);
|
||||
if(!match){
|
||||
match = superRegex.exec(src);
|
||||
if(match)
|
||||
isSuper = true;
|
||||
}
|
||||
if(match?.length) {
|
||||
return {
|
||||
type : 'superSubScript', // Should match "name" above
|
||||
raw : match[0], // Text to consume from the source
|
||||
tag : isSuper ? 'sup' : 'sub',
|
||||
tokens : this.lexer.inlineTokens(match[1])
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer(token) {
|
||||
return `<${token.tag}>${this.parser.parseInline(token.tokens)}</${token.tag}>`;
|
||||
}
|
||||
};
|
||||
|
||||
const definitionLists = {
|
||||
name : 'definitionLists',
|
||||
level : 'block',
|
||||
@@ -237,7 +265,7 @@ const definitionLists = {
|
||||
}
|
||||
};
|
||||
|
||||
Marked.use({ extensions: [mustacheSpans, mustacheDivs, mustacheInjectInline, definitionLists] });
|
||||
Marked.use({ extensions: [mustacheSpans, mustacheDivs, mustacheInjectInline, definitionLists, superSubScripts] });
|
||||
Marked.use(mustacheInjectBlock);
|
||||
Marked.use({ renderer: renderer, mangle: false });
|
||||
Marked.use(MarkedExtendedTables(), MarkedGFMHeadingId(), MarkedSmartypantsLite());
|
||||
|
||||
Reference in New Issue
Block a user