mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-25 15:35:13 +00:00
merge: allow "math block" inline (#6)
This commit is contained in:
commit
d05b5b629f
2 changed files with 7 additions and 7 deletions
|
@ -247,16 +247,14 @@ export const language = P.createLanguage({
|
||||||
const close = P.str('\\]');
|
const close = P.str('\\]');
|
||||||
return P.seq([
|
return P.seq([
|
||||||
newLine.option(),
|
newLine.option(),
|
||||||
P.lineBegin,
|
|
||||||
open,
|
open,
|
||||||
newLine.option(),
|
newLine.option(),
|
||||||
P.seq([P.notMatch(P.seq([newLine.option(), close])), P.char], 1).many(1),
|
P.seq([P.notMatch(P.seq([newLine.option(), close])), P.char], 1).many(1),
|
||||||
newLine.option(),
|
newLine.option(),
|
||||||
close,
|
close,
|
||||||
P.lineEnd,
|
|
||||||
newLine.option(),
|
newLine.option(),
|
||||||
]).map(result => {
|
]).map(result => {
|
||||||
const formula = (result[4] as string[]).join('');
|
const formula = (result[3] as string[]).join('');
|
||||||
return M.MATH_BLOCK(formula);
|
return M.MATH_BLOCK(formula);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -291,17 +291,19 @@ hoge`;
|
||||||
];
|
];
|
||||||
assert.deepStrictEqual(mfm.parse(input), output);
|
assert.deepStrictEqual(mfm.parse(input), output);
|
||||||
});
|
});
|
||||||
test('行末以外に閉じタグがある場合はマッチしない', () => {
|
test('行末以外に閉じタグがある場合はマッチする', () => {
|
||||||
const input = '\\[aaa\\]after';
|
const input = '\\[aaa\\]after';
|
||||||
const output = [
|
const output = [
|
||||||
TEXT('\\[aaa\\]after')
|
MATH_BLOCK('aaa'),
|
||||||
|
TEXT('after'),
|
||||||
];
|
];
|
||||||
assert.deepStrictEqual(mfm.parse(input), output);
|
assert.deepStrictEqual(mfm.parse(input), output);
|
||||||
});
|
});
|
||||||
test('行頭以外に開始タグがある場合はマッチしない', () => {
|
test('行頭以外に開始タグがある場合はマッチする', () => {
|
||||||
const input = 'before\\[aaa\\]';
|
const input = 'before\\[aaa\\]';
|
||||||
const output = [
|
const output = [
|
||||||
TEXT('before\\[aaa\\]')
|
TEXT('before'),
|
||||||
|
MATH_BLOCK('aaa'),
|
||||||
];
|
];
|
||||||
assert.deepStrictEqual(mfm.parse(input), output);
|
assert.deepStrictEqual(mfm.parse(input), output);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue