aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2020-05-08 04:25:53 +0200
committerache <ache@ache.one>2020-05-08 04:25:53 +0200
commitabd80cd6e2d61c61a7d042d7515b923dc8460d63 (patch)
treed3137c66332c16f2fbd59a0158f813dff6043b1b
parentUpdate README.md (diff)
Add support for autolinks
-rw-r--r--__tests__/index.js10
-rw-r--r--dist/index.js2
-rw-r--r--src/index.js2
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('<p>This is a link :<a href="ache.one" ping="http://ache.one/big.brother">Test link</a></p>'));
+ t.deepEqual(parse(contents), parse('<p>This is a link :<a href="ache.one" ping="https://ache.one/big.brother">Test link</a></p>'));
+});
+
+test('autolink', t => {
+ const linkMd = 'This is a link :<https://ache.one>{ ping="https://ache.one/big.brother"}';
+ const {contents} = render(linkMd);
+ t.deepEqual(parse(contents), parse('<p>This is a link :<a href="https://ache.one" ping="https://ache.one/big.brother">https://ache.one</a></p>'));
});
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']);