mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-21 21:55:09 +00:00
allow "math block" inline
previously, a math block would only be recognised when on its own line
This commit is contained in:
parent
3eb78bc54f
commit
5f50e38f31
2 changed files with 7 additions and 7 deletions
|
@ -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);
|
||||
});
|
||||
},
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue