diff --git a/src/parser/internal.ts b/src/parser/internal.ts index 95ae861..3a96915 100644 --- a/src/parser/internal.ts +++ b/src/parser/internal.ts @@ -55,7 +55,7 @@ function parseMrkdwn( case 'link': { return `<${element.href}|${element.tokens .flatMap(child => parseMrkdwn(child as typeof element)) - .join('')}> `; + .join('')}>`; } case 'em': { diff --git a/test/integration.spec.ts b/test/integration.spec.ts index 83cd703..0180089 100644 --- a/test/integration.spec.ts +++ b/test/integration.spec.ts @@ -46,7 +46,7 @@ a **b** _c_ **_d_ e** '59953191-480px' ), slack.section('> block quote *a*\n> block quote b'), - slack.section(' '), + slack.section(''), slack.section('• bullet _a_\n• bullet _b_'), slack.section('1. number _a_\n2. number _b_'), slack.section('• checkbox false\n• checkbox true'), diff --git a/test/parser.spec.ts b/test/parser.spec.ts index a1260d1..1161b7a 100644 --- a/test/parser.spec.ts +++ b/test/parser.spec.ts @@ -7,7 +7,22 @@ describe('parser', () => { const tokens = marked.lexer('**a ~b~** c[*d*](https://example.com)'); const actual = parseBlocks(tokens); - const expected = [slack.section('*a ~b~* c ')]; + const expected = [slack.section('*a ~b~* c')]; + + expect(actual).toStrictEqual(expected); + }); + + it('should not add extra spaces around inline links', () => { + const tokens = marked.lexer( + '- test [abc1234](https://example.com/commit/abc1234) by @user ([DES-123](https://jira.example/DES-123)) ([#456](https://github.example/pull/456))' + ); + const actual = parseBlocks(tokens); + + const expected = [ + slack.section( + '• test by @user () ()' + ), + ]; expect(actual).toStrictEqual(expected); });