From 703f82215d418d96f5e30929fbc76ce800c3c677 Mon Sep 17 00:00:00 2001 From: marihachi Date: Fri, 1 Oct 2021 22:05:11 +0900 Subject: [PATCH] remove fn v1 syntax (#79) --- docs/syntax.md | 18 ------------------ src/internal/parser.pegjs | 20 ++++---------------- test/parser.ts | 38 ++------------------------------------ 3 files changed, 6 insertions(+), 70 deletions(-) diff --git a/docs/syntax.md b/docs/syntax.md index 84dc965..676fdfd 100644 --- a/docs/syntax.md +++ b/docs/syntax.md @@ -607,24 +607,6 @@ $[shake.speed=1s 🍮] $[flip.h,v MisskeyでFediverseの世界が広がります] ``` -構文2: -**廃止予定の構文。代替の構文(構文1)が用意されています。** -``` -[shake 🍮] -``` - -``` -[spin.alternate 🍮] -``` - -``` -[shake.speed=1s 🍮] -``` - -``` -[flip.h,v MisskeyでFediverseの世界が広がります] -``` - ## 詳細 - 内容には再度InlineParserを適用する。 - 内容には改行も含めることが可能です。 diff --git a/src/internal/parser.pegjs b/src/internal/parser.pegjs index 7abc8de..9b6e3ac 100644 --- a/src/internal/parser.pegjs +++ b/src/internal/parser.pegjs @@ -92,9 +92,8 @@ full / mention / hashtag / url - / fnVer2 + / fn / link - / fnVer1 / search // block / inlineText @@ -111,9 +110,8 @@ inline / mention / hashtag / url - / fnVer2 + / fn / link - / fnVer1 / inlineText plain @@ -415,15 +413,8 @@ linkUrl // inline: fn -fnVer1 - = "[" name:$([a-z0-9_]i)+ args:fnArgs? _ content:fnContentPart+ "]" -{ - args = args || {}; - return FN(name, args, mergeText(content)); -} - -fnVer2 - = "$[" name:$([a-z0-9_]i)+ args:fnArgs? _ content:fnContentPart+ "]" +fn + = "$[" name:$([a-z0-9_]i)+ args:fnArgs? _ content:(!("]") @inline)+ "]" { args = args || {}; return FN(name, args, mergeText(content)); @@ -449,9 +440,6 @@ fnArg return { k: k, v: true }; } -fnContentPart - = !("]") @inline - // inline: text inlineText diff --git a/test/parser.ts b/test/parser.ts index 048084c..b36e505 100644 --- a/test/parser.ts +++ b/test/parser.ts @@ -1018,41 +1018,7 @@ hoge`; }); }); - describe('fn v1', () => { - it('basic', () => { - const input = '[tada abc]'; - const output = [ - FN('tada', { }, [ - TEXT('abc') - ]) - ]; - assert.deepStrictEqual(mfm.parse(input), output); - }); - - it('with a string argument', () => { - const input = '[spin.speed=1.1s a]'; - const output = [ - FN('spin', { speed: '1.1s' }, [ - TEXT('a') - ]) - ]; - assert.deepStrictEqual(mfm.parse(input), output); - }); - - it('nest', () => { - const input = '[spin.speed=1.1s [shake a]]'; - const output = [ - FN('spin', { speed: '1.1s' }, [ - FN('shake', { }, [ - TEXT('a') - ]) - ]) - ]; - assert.deepStrictEqual(mfm.parse(input), output); - }); - }); - - describe('fn v2', () => { + describe('fn', () => { it('basic', () => { const input = '$[tada abc]'; const output = [ @@ -1090,7 +1056,7 @@ hoge`; const input = `before
-Hello [tada everynyan! 🎉] +Hello $[tada everynyan! 🎉] I'm @ai, A bot of misskey!