2017-03-17 11:16:32 -05:00
|
|
|
/**
|
|
|
|
* Link
|
|
|
|
*/
|
|
|
|
|
|
|
|
module.exports = text => {
|
2017-03-17 14:20:25 -05:00
|
|
|
const match = text.match(/^\??\[([^\[\]]+?)\]\((https?:\/\/[\w\/:%#@\$&\?!\(\)\[\]~\.=\+\-]+?)\)/);
|
2017-03-17 11:16:32 -05:00
|
|
|
if (!match) return null;
|
|
|
|
const silent = text[0] == '?';
|
|
|
|
const link = match[0];
|
|
|
|
const title = match[1];
|
|
|
|
const url = match[2];
|
|
|
|
return {
|
|
|
|
type: 'link',
|
|
|
|
content: link,
|
|
|
|
title: title,
|
|
|
|
url: url,
|
|
|
|
silent: silent
|
|
|
|
};
|
|
|
|
};
|