diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-01-20 17:52:11 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-01-20 17:52:11 +0900 |
| commit | f8ba73bebf1763b5182321388d2ce1d081605eb3 (patch) | |
| tree | ef69008a0e4f3976201d872b036e11b09bf258da | |
| parent | Remove unused import (diff) | |
| download | misskey-f8ba73bebf1763b5182321388d2ce1d081605eb3.tar.gz misskey-f8ba73bebf1763b5182321388d2ce1d081605eb3.tar.bz2 misskey-f8ba73bebf1763b5182321388d2ce1d081605eb3.zip | |
[MFM] Add <i> syntax
| -rw-r--r-- | src/mfm/parser.ts | 2 | ||||
| -rw-r--r-- | test/mfm.ts | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/mfm/parser.ts b/src/mfm/parser.ts index f377d18611..2ab38d97a8 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(/<i>([\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 44e7d6904e..e9253ebc43 100644 --- a/test/mfm.ts +++ b/test/mfm.ts @@ -883,6 +883,15 @@ describe('MFM', () => { }); describe('italic', () => { + it('<i>', () => { + const tokens = analyze('<i>foo</i>'); + assert.deepStrictEqual(tokens, [ + tree('italic', [ + text('foo') + ], {}), + ]); + }); + it('underscore', () => { const tokens = analyze('_foo_'); assert.deepStrictEqual(tokens, [ |