Skip to content
Snippets Groups Projects
Unverified Commit daba7fe8 authored by syuilo's avatar syuilo
Browse files

[MFM] Fix title syntax parsing

parent afc9caf7
No related branches found
No related tags found
No related merge requests found
......@@ -8,8 +8,8 @@ export type TextElementTitle = {
title: string
};
export default function(text: string) {
const match = text.match(/^(【|\[)(.+?)(】|])\n/);
export default function(text: string, i: number) {
const match = i == 0 ? text.match(/^(【|\[)(.+?)(】|])\n/) : text.match(/^\n(【|\[)(.+?)(】|])\n/);
if (!match) return null;
const title = match[0];
return {
......
......@@ -230,6 +230,11 @@ describe('Text', () => {
assert.deepEqual(
{ type: 'title', content: '[yee]\n', title: 'yee'}
, tokens2[0]);
const tokens3 = analyze('a [a]\nb [b]\nc [c]');
assert.deepEqual(
{ type: 'text', content: 'a [a]\nb [b]\nc [c]' }
, tokens2[0]);
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment