0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-25 03:12:40 +00:00

Simple Underline token.

Overrides __
This commit is contained in:
David Bolack
2023-12-13 17:37:05 -06:00
parent 67a4391dcb
commit 04187cf769

View File

@@ -239,9 +239,24 @@ const underline = {
level : 'inline',
start(src) { return src.match(/\w_[^_]_/m)?.index;},
tokenizer(src, tokens) {
const uRegex = /^_(?!\s)(?=([^_]*[^\s]))\1\^/m;
const uRegex = /^_([^_]*)_/m;
const match = uRegex.exec(src);
console.log('Looking');
if(match?.length) {
console.log('found!');
console.log(match);
return {
type : 'underline',
raw : match[0],
tokens : this.lexer.inlineTokens(match[1])
};
}
},
renderer(token) {
console.log()
return `<u>${this.parser.parseInline(token.tokens)}</u>`;
}
}
};
const definitionLists = {
name : 'definitionLists',
@@ -275,7 +290,7 @@ const definitionLists = {
}
};
Marked.use({ extensions: [mustacheSpans, mustacheDivs, mustacheInjectInline, definitionLists, superSubScripts] });
Marked.use({ extensions: [mustacheSpans, mustacheDivs, mustacheInjectInline, definitionLists, superSubScripts, underline] });
Marked.use(mustacheInjectBlock);
Marked.use({ renderer: renderer, mangle: false });
Marked.use(MarkedExtendedTables(), MarkedGFMHeadingId(), MarkedSmartypantsLite());