From abd80cd6e2d61c61a7d042d7515b923dc8460d63 Mon Sep 17 00:00:00 2001 From: ache Date: Fri, 8 May 2020 04:25:53 +0200 Subject: Add support for autolinks --- __tests__/index.js | 10 ++++++++-- dist/index.js | 2 +- src/index.js | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/__tests__/index.js b/__tests__/index.js index bce565b..6401426 100644 --- a/__tests__/index.js +++ b/__tests__/index.js @@ -125,9 +125,15 @@ test('image', t => { }); test('link', t => { - const linkMd = 'This is a link :[Test link](ache.one){ ping="http://ache.one/big.brother"}'; + const linkMd = 'This is a link :[Test link](ache.one){ ping="https://ache.one/big.brother"}'; const {contents} = render(linkMd); - t.deepEqual(parse(contents), parse('

This is a link :Test link

')); + t.deepEqual(parse(contents), parse('

This is a link :Test link

')); +}); + +test('autolink', t => { + const linkMd = 'This is a link :{ ping="https://ache.one/big.brother"}'; + const {contents} = render(linkMd); + t.deepEqual(parse(contents), parse('

This is a link :https://ache.one

')); }); test('header', t => { diff --git a/dist/index.js b/dist/index.js index 3ad2d1a..447eeb1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -12,7 +12,7 @@ var htmlElemAttr = require('html-element-attributes'); var isWhiteSpace = require('is-whitespace-character'); -var supportedElements = new Set(['link', 'atxHeading', 'strong', 'emphasis', 'deletion', 'code', 'setextHeading', 'fencedCode', 'reference', 'footnoteCall']); +var supportedElements = new Set(['link', 'atxHeading', 'strong', 'emphasis', 'deletion', 'code', 'setextHeading', 'fencedCode', 'reference', 'footnoteCall', 'autoLink']); var blockElements = new Set(['atxHeading', 'setextHeading']); var particularElements = new Set(['fencedCode']); var particularTokenize = {}; diff --git a/src/index.js b/src/index.js index d956851..83eb0c1 100644 --- a/src/index.js +++ b/src/index.js @@ -4,7 +4,7 @@ const parseAttr = require('md-attr-parser'); const htmlElemAttr = require('html-element-attributes'); const isWhiteSpace = require('is-whitespace-character'); -const supportedElements = new Set(['link', 'atxHeading', 'strong', 'emphasis', 'deletion', 'code', 'setextHeading', 'fencedCode', 'reference', 'footnoteCall']); +const supportedElements = new Set(['link', 'atxHeading', 'strong', 'emphasis', 'deletion', 'code', 'setextHeading', 'fencedCode', 'reference', 'footnoteCall', 'autoLink']); const blockElements = new Set(['atxHeading', 'setextHeading']); const particularElements = new Set(['fencedCode']); -- cgit v1.2.3