diff --git a/dev/lib/syntax.js b/dev/lib/syntax.js index 8295617..1457c80 100644 --- a/dev/lib/syntax.js +++ b/dev/lib/syntax.js @@ -28,12 +28,23 @@ const emailDomainDotTrail = { partial: true } -const wwwAutolink = {tokenize: tokenizeWwwAutolink, previous: previousWww} +const wwwAutolink = { + name: 'wwwAutolink', + tokenize: tokenizeWwwAutolink, + previous: previousWww +} + const protocolAutolink = { + name: 'protocolAutolink', tokenize: tokenizeProtocolAutolink, previous: previousProtocol } -const emailAutolink = {tokenize: tokenizeEmailAutolink, previous: previousEmail} + +const emailAutolink = { + name: 'emailAutolink', + tokenize: tokenizeEmailAutolink, + previous: previousEmail +} /** @type {ConstructRecord} */ const text = {} diff --git a/test/index.js b/test/index.js index dd02e8d..6797b8d 100644 --- a/test/index.js +++ b/test/index.js @@ -19,6 +19,55 @@ test('micromark-extension-gfm-autolink-literal', async function (t) { ) }) + await t.test( + 'should skip wwwAutolink construct if `disable.null` includes `wwwAutolink`', + async function () { + assert.equal( + micromark('www.a.com', { + extensions: [ + gfmAutolinkLiteral(), + {disable: {null: ['wwwAutolink']}} + ], + htmlExtensions: [gfmAutolinkLiteralHtml()] + }), + '

www.a.com

' + ) + } + ) + + await t.test( + 'should skip protocolAutolink construct if `disable.null` includes `protocolAutolink`', + async function () { + assert.equal( + micromark('http://a.com', { + extensions: [ + gfmAutolinkLiteral(), + {disable: {null: ['protocolAutolink']}} + ], + htmlExtensions: [gfmAutolinkLiteralHtml()] + }), + '

http://a.com

' + ) + } + ) + + await t.test( + 'should skip emailAutolink construct if `disable.null` includes `emailAutolink`', + async function () { + assert.equal( + micromark('a@b.com', { + extensions: [ + gfmAutolinkLiteral(), + {disable: {null: ['emailAutolink']}} + ], + htmlExtensions: [gfmAutolinkLiteralHtml()] + }), + '

a@b.com

' + ) + } + ) + + await t.test('should support a closing paren at TLD', async function () { assert.equal( micromark('www.a.)', {