merge: allow "math block" inline (#6)

This commit is contained in:
Marie 2024-01-08 22:17:22 +01:00
commit d05b5b629f
2 changed files with 7 additions and 7 deletions

View file

@ -247,16 +247,14 @@ export const language = P.createLanguage({
const close = P.str('\\]');
return P.seq([
newLine.option(),
P.lineBegin,
open,
newLine.option(),
P.seq([P.notMatch(P.seq([newLine.option(), close])), P.char], 1).many(1),
newLine.option(),
close,
P.lineEnd,
newLine.option(),
]).map(result => {
const formula = (result[4] as string[]).join('');
const formula = (result[3] as string[]).join('');
return M.MATH_BLOCK(formula);
});
},

View file

@ -291,17 +291,19 @@ hoge`;
];
assert.deepStrictEqual(mfm.parse(input), output);
});
test('行末以外に閉じタグがある場合はマッチしない', () => {
test('行末以外に閉じタグがある場合はマッチする', () => {
const input = '\\[aaa\\]after';
const output = [
TEXT('\\[aaa\\]after')
MATH_BLOCK('aaa'),
TEXT('after'),
];
assert.deepStrictEqual(mfm.parse(input), output);
});
test('行頭以外に開始タグがある場合はマッチしない', () => {
test('行頭以外に開始タグがある場合はマッチする', () => {
const input = 'before\\[aaa\\]';
const output = [
TEXT('before\\[aaa\\]')
TEXT('before'),
MATH_BLOCK('aaa'),
];
assert.deepStrictEqual(mfm.parse(input), output);
});