[MFM] Fix title parsing

This commit is contained in:
syuilo 2018-11-07 21:17:27 +09:00
parent a29d7a0475
commit 4c81e400c4
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
1 changed files with 2 additions and 3 deletions

View File

@ -11,10 +11,9 @@ export type TextElementTitle = {
export default function(text: string, isBegin: boolean) { export default function(text: string, isBegin: boolean) {
const match = isBegin ? text.match(/^(【|\[)(.+?)(】|])\n/) : text.match(/^\n(【|\[)(.+?)(】|])\n/); const match = isBegin ? text.match(/^(【|\[)(.+?)(】|])\n/) : text.match(/^\n(【|\[)(.+?)(】|])\n/);
if (!match) return null; if (!match) return null;
const title = match[0];
return { return {
type: 'title', type: 'title',
content: title, content: match[0],
title: title.substr(1, title.length - 3) title: match[2]
} as TextElementTitle; } as TextElementTitle;
} }