From 9d93e1d659e91995fab5f89991444d1b1559319b Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 20 Jan 2019 17:52:11 +0900 Subject: [PATCH] [MFM] Add syntax --- src/mfm/parser.ts | 2 +- test/mfm.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mfm/parser.ts b/src/mfm/parser.ts index f377d1861..2ab38d97a 100644 --- a/src/mfm/parser.ts +++ b/src/mfm/parser.ts @@ -224,7 +224,7 @@ const mfm = P.createLanguage({ //#region Italic italic: r => - P.regexp(/(\*|_)([a-zA-Z0-9]+?[\s\S]*?)\1/, 2) + P.alt(P.regexp(/([\s\S]+?)<\/i>/, 1), P.regexp(/(\*|_)([a-zA-Z0-9]+?[\s\S]*?)\1/, 2)) .map(x => createTree('italic', P.alt( r.bold, r.strike, diff --git a/test/mfm.ts b/test/mfm.ts index 44e7d6904..e9253ebc4 100644 --- a/test/mfm.ts +++ b/test/mfm.ts @@ -883,6 +883,15 @@ describe('MFM', () => { }); describe('italic', () => { + it('', () => { + const tokens = analyze('foo'); + assert.deepStrictEqual(tokens, [ + tree('italic', [ + text('foo') + ], {}), + ]); + }); + it('underscore', () => { const tokens = analyze('_foo_'); assert.deepStrictEqual(tokens, [