mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-09 18:02:39 +00:00
Change to 1 and 2 ^'s . Slight cleanup
This commit is contained in:
@@ -207,34 +207,30 @@ const mustacheInjectBlock = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const superSubScripts = {
|
const superSubScripts = {
|
||||||
name : 'superSubScripts',
|
name : 'superSubScript',
|
||||||
level : 'inline',
|
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) {
|
tokenizer(src, tokens) {
|
||||||
const superRegex = /^\^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^\^/m;
|
const superRegex = /^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^/m;
|
||||||
const subRegex = /^\^\^\^([^\s\^][^\^]*[^\s\^])\^\^\^/m;
|
const subRegex = /^\^\^(?!\s)(?=([^\n\^]*[^\s\^]))\1\^\^/m;
|
||||||
let isSuper = false;
|
let isSuper = false;
|
||||||
let match = subRegex.exec(src);
|
let match = subRegex.exec(src);
|
||||||
if(!match){
|
if(!match){
|
||||||
match = superRegex.exec(src);
|
match = superRegex.exec(src);
|
||||||
if(match) {
|
if(match)
|
||||||
isSuper = true;
|
isSuper = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(match?.length) {
|
if(match?.length) {
|
||||||
const tags = this.lexer.inlineTokens(match[1]);
|
|
||||||
return {
|
return {
|
||||||
type : 'superSubScripts', // Should match "name" above
|
type : 'superSubScript', // Should match "name" above
|
||||||
raw : match[0], // Text to consume from the source
|
raw : match[0], // Text to consume from the source
|
||||||
text : src,
|
tag : isSuper ? 'sup' : 'sub',
|
||||||
super : isSuper,
|
tokens : this.lexer.inlineTokens(match[1])
|
||||||
tags
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
renderer(token) {
|
renderer(token) {
|
||||||
const tag = token.super ? 'sup' : 'sub';
|
return `<${token.tag}>${this.parser.parseInline(token.tokens)}</${token.tag}>`;
|
||||||
return `<${tag}>${this.parser.parseInline(token.tags)}</${tag}>`;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user