diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-01-20 18:06:04 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-01-20 18:06:04 +0900 |
| commit | 1df9c1005f6be20e03a55e3ba203e5cdc1fa9eba (patch) | |
| tree | c4be1eef6db37f4b01e68414aa5a2159b2732180 | |
| parent | Add double underscore syntax for bold markdown (#3733) (diff) | |
| download | misskey-1df9c1005f6be20e03a55e3ba203e5cdc1fa9eba.tar.gz misskey-1df9c1005f6be20e03a55e3ba203e5cdc1fa9eba.tar.bz2 misskey-1df9c1005f6be20e03a55e3ba203e5cdc1fa9eba.zip | |
[MFM] __ 構文はアルファベットのみに
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | src/mfm/parser.ts | 2 | ||||
| -rw-r--r-- | test/mfm.ts | 7 |
3 files changed, 9 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 451ed3fdcf..1450a9775e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ unreleased * ログイン時に二段階認証が分かりにくいのを改善 * 投稿のツールチップを出すのは時間の上だけに変更 * `*`や`_`でもイタリック構文を使えるように(アルファベットのみ) +* `__`でも太字構文を使えるように(アルファベットのみ) * ハッシュタグ判定の強化 * ストーク機能の廃止 * 関係のない返信がタイムラインに流れる問題を修正 diff --git a/src/mfm/parser.ts b/src/mfm/parser.ts index c271b62e23..10b16d619a 100644 --- a/src/mfm/parser.ts +++ b/src/mfm/parser.ts @@ -154,7 +154,7 @@ const mfm = P.createLanguage({ //#region Bold bold: r => - P.regexp(/(\*\*|__)([\s\S]+?)\1/, 2) + P.alt(P.regexp(/\*\*([\s\S]+?)\*\*/, 1), P.regexp(/__([a-zA-Z0-9\s]+?)__/, 1)) .map(x => createTree('bold', P.alt( r.strike, r.italic, diff --git a/test/mfm.ts b/test/mfm.ts index bacce017c2..54096e6bb0 100644 --- a/test/mfm.ts +++ b/test/mfm.ts @@ -187,6 +187,13 @@ describe('MFM', () => { ]); }); + it('with underscores (ensure it allows alphabet only)', () => { + const tokens = analyze('(=^・__________・^=)'); + assert.deepStrictEqual(tokens, [ + text('(=^・__________・^=)') + ]); + }); + it('mixed syntax', () => { const tokens = analyze('**foo__'); assert.deepStrictEqual(tokens, [ |