Skip to content

Commit

Permalink
Add name
Browse files Browse the repository at this point in the history
Closes GH-10.

Reviewed-by: Titus Wormer <[email protected]>
  • Loading branch information
shlroland authored Jul 5, 2024
1 parent be44bab commit 445c6a4
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
15 changes: 13 additions & 2 deletions dev/lib/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
49 changes: 49 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
}),
'<p>www.a.com</p>'
)
}
)

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()]
}),
'<p>http://a.com</p>'
)
}
)

await t.test(
'should skip emailAutolink construct if `disable.null` includes `emailAutolink`',
async function () {
assert.equal(
micromark('[email protected]', {
extensions: [
gfmAutolinkLiteral(),
{disable: {null: ['emailAutolink']}}
],
htmlExtensions: [gfmAutolinkLiteralHtml()]
}),
'<p>[email protected]</p>'
)
}
)


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

0 comments on commit 445c6a4

Please sign in to comment.