mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-09 11:32:39 +00:00
Hack to avoid conflict with emojis
This commit is contained in:
@@ -299,17 +299,26 @@ const superSubScripts = {
|
|||||||
const definitionListsInline = {
|
const definitionListsInline = {
|
||||||
name : 'definitionListsInline',
|
name : 'definitionListsInline',
|
||||||
level : 'block',
|
level : 'block',
|
||||||
start(src) { return src.match(/^[^\n]*?::[^\n]*/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
start(src) { return src.match(/\n[^\n]*?::[^\n]*/m)?.index; }, // Hint to Marked.js to stop and check for a match
|
||||||
tokenizer(src, tokens) {
|
tokenizer(src, tokens) {
|
||||||
const regex = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym;
|
const regex = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym;
|
||||||
let match;
|
let match;
|
||||||
let endIndex = 0;
|
let endIndex = 0;
|
||||||
const definitions = [];
|
const definitions = [];
|
||||||
while (match = regex.exec(src)) {
|
while (match = regex.exec(src)) {
|
||||||
definitions.push({
|
let originalLine = match[0]; // This line and below to handle conflict with emojis
|
||||||
dt : this.lexer.inlineTokens(match[1].trim()),
|
let firstLine = originalLine; // Remove in V4 when definitionListsInline updated to
|
||||||
dd : this.lexer.inlineTokens(match[2].trim())
|
this.lexer.inlineTokens(firstLine.trim()) // require spaces around `::`
|
||||||
});
|
.filter(t => t.type == 'emoji')
|
||||||
|
.map(emoji => firstLine = firstLine.replace(emoji.raw, 'x'.repeat(emoji.raw.length)));
|
||||||
|
|
||||||
|
let newMatch = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym.exec(firstLine);
|
||||||
|
if(newMatch) {
|
||||||
|
definitions.push({
|
||||||
|
dt : this.lexer.inlineTokens(originalLine.slice(0, newMatch[1].length).trim()),
|
||||||
|
dd : this.lexer.inlineTokens(originalLine.slice(newMatch[1].length + 2).trim())
|
||||||
|
});
|
||||||
|
} // End of emoji hack.
|
||||||
endIndex = regex.lastIndex;
|
endIndex = regex.lastIndex;
|
||||||
}
|
}
|
||||||
if(definitions.length) {
|
if(definitions.length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user