From bb92158dff6161aa39d71a0d5fb42dfb0d656c40 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 31 Jan 2019 12:10:48 +0900 Subject: [PATCH] [MFM] Make some syntax block Resolve #3508 --- src/mfm/language.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mfm/language.ts b/src/mfm/language.ts index 1876e611f8..8f35d443dc 100644 --- a/src/mfm/language.ts +++ b/src/mfm/language.ts @@ -27,7 +27,9 @@ export const mfmLanguage = P.createLanguage({ r.title, r.quote, r.search, - r.blockCode + r.blockCode, + r.mathBlock, + r.center, ), startOfLine: () => P((input, i) => { if (i == 0 || input[i] == '\n' || input[i - 1] == '\n') { @@ -75,9 +77,7 @@ export const mfmLanguage = P.createLanguage({ r.spin, r.jump, r.flip, - r.center, r.inlineCode, - r.mathBlock, r.mathInline, r.mention, r.hashtag, @@ -123,9 +123,9 @@ export const mfmLanguage = P.createLanguage({ }, jump: r => P.regexp(/(.+?)<\/jump>/, 1).map(x => createTree('jump', r.inline.atLeast(1).tryParse(x), {})), flip: r => P.regexp(/(.+?)<\/flip>/, 1).map(x => createTree('flip', r.inline.atLeast(1).tryParse(x), {})), - center: r => P.regexp(/
([\s\S]+?)<\/center>/, 1).map(x => createTree('center', r.inline.atLeast(1).tryParse(x), {})), + center: r => r.startOfLine.then(P.regexp(/
([\s\S]+?)<\/center>/, 1).map(x => createTree('center', r.inline.atLeast(1).tryParse(x), {}))), inlineCode: () => P.regexp(/`([^ยด\n]+?)`/, 1).map(x => createLeaf('inlineCode', { code: x })), - mathBlock: () => P.regexp(/\\\[([\s\S]+?)\\\]/, 1).map(x => createLeaf('mathBlock', { formula: x.trim() })), + mathBlock: r => r.startOfLine.then(P.regexp(/\\\[([\s\S]+?)\\\]/, 1).map(x => createLeaf('mathBlock', { formula: x.trim() }))), mathInline: () => P.regexp(/\\\((.+?)\\\)/, 1).map(x => createLeaf('mathInline', { formula: x })), mention: () => { return P((input, i) => {