[MFM] Improve italic syntax detection
This commit is contained in:
@ -224,7 +224,16 @@ const mfm = P.createLanguage({
|
||||
|
||||
//#region Italic
|
||||
italic: r =>
|
||||
P.alt(P.regexp(/<i>([\s\S]+?)<\/i>/, 1), P.regexp(/(\*|_)([a-zA-Z0-9]+?[\s\S]*?)\1/, 2))
|
||||
P.alt(
|
||||
P.regexp(/<i>([\s\S]+?)<\/i>/, 1),
|
||||
P((input, i) => {
|
||||
const text = input.substr(i);
|
||||
const match = text.match(/^(\*|_)([a-zA-Z0-9]+?[\s\S]*?)\1/);
|
||||
if (!match) return P.makeFailure(i, 'not a italic');
|
||||
if (input[i - 1] != null && input[i - 1].match(/[a-z0-9]/i)) return P.makeFailure(i, 'not a italic');
|
||||
return P.makeSuccess(i + match[0].length, match[2]);
|
||||
})
|
||||
)
|
||||
.map(x => createTree('italic', P.alt(
|
||||
r.bold,
|
||||
r.strike,
|
||||
|
Reference in New Issue
Block a user