mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-22 18:07:31 -07:00
[MFM] Fix title syntax parsing
This commit is contained in:
parent
c23a9abeb1
commit
a0a3786b69
2 changed files with 7 additions and 2 deletions
|
@ -8,8 +8,8 @@ export type TextElementTitle = {
|
||||||
title: string
|
title: string
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function(text: string) {
|
export default function(text: string, i: number) {
|
||||||
const match = text.match(/^(【|\[)(.+?)(】|])\n/);
|
const match = i == 0 ? text.match(/^(【|\[)(.+?)(】|])\n/) : text.match(/^\n(【|\[)(.+?)(】|])\n/);
|
||||||
if (!match) return null;
|
if (!match) return null;
|
||||||
const title = match[0];
|
const title = match[0];
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -230,6 +230,11 @@ describe('Text', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
{ type: 'title', content: '[yee]\n', title: 'yee'}
|
{ type: 'title', content: '[yee]\n', title: 'yee'}
|
||||||
, tokens2[0]);
|
, tokens2[0]);
|
||||||
|
|
||||||
|
const tokens3 = analyze('a [a]\nb [b]\nc [c]');
|
||||||
|
assert.deepEqual(
|
||||||
|
{ type: 'text', content: 'a [a]\nb [b]\nc [c]' }
|
||||||
|
, tokens2[0]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue