From 0ecd1de57c4aa372dcc40a4cc4775556013e875f Mon Sep 17 00:00:00 2001 From: marihachi Date: Sat, 3 Apr 2021 15:44:33 +0900 Subject: [PATCH] parses the link in the link node as text node. --- src/parser.pegjs | 1 + test/main.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/parser.pegjs b/src/parser.pegjs index e38db35..b517237 100644 --- a/src/parser.pegjs +++ b/src/parser.pegjs @@ -343,6 +343,7 @@ link linkLabelPart = url { return text(); /* text node */ } + / link { return text(); /* text node */ } / !"]" n:inline { return n; } linkUrl diff --git a/test/main.ts b/test/main.ts index 52acbd8..cdb05ea 100644 --- a/test/main.ts +++ b/test/main.ts @@ -457,6 +457,18 @@ describe('link', () => { ]; assert.deepStrictEqual(parse(input), output); }); + + it('do not yield link node even if label is recognisable as a link', () => { + const input = 'official instance: [[https://misskey.io/@ai](https://misskey.io/@ai)](https://misskey.io/@ai).'; + const output = [ + TEXT('official instance: '), + LINK(false, 'https://misskey.io/@ai', [ + TEXT('[https://misskey.io/@ai](https://misskey.io/@ai)') + ]), + TEXT('.') + ]; + assert.deepStrictEqual(parse(input), output); + }); }); describe('fn', () => {