0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-27 02:52:43 +00:00

Change to 1 and 2 ^'s . Slight cleanup

This commit is contained in:
Trevor Buckner
2023-12-04 22:11:05 -05:00
parent 6bf51cd94a
commit 38fa428fde

View File

@@ -207,34 +207,30 @@ const mustacheInjectBlock = {
};
const superSubScripts = {
name : 'superSubScripts',
name : 'superSubScript',
level : 'inline',
start(src) { return src.match(/\^\^/m)?.index; }, // Hint to Marked.js to stop and check for a match
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\^][^\^]*[^\s\^])\^\^\^/m;
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) {
if(match)
isSuper = true;
}
}
if(match?.length) {
const tags = this.lexer.inlineTokens(match[1]);
return {
type : 'superSubScripts', // Should match "name" above
raw : match[0], // Text to consume from the source
text : src,
super : isSuper,
tags
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) {
const tag = token.super ? 'sup' : 'sub';
return `<${tag}>${this.parser.parseInline(token.tags)}</${tag}>`;
return `<${token.tag}>${this.parser.parseInline(token.tokens)}</${token.tag}>`;
}
};