|
|
@ -11,7 +11,7 @@ var AUTOLINK_RE = /^<([a-zA-Z.\-]{1,25}):([^<>\x00-\x20]*)>/; |
|
|
|
|
|
|
|
|
|
|
|
module.exports = function autolink(state) { |
|
|
|
var tail, linkMatch, emailMatch, pos = state.pos; |
|
|
|
var tail, linkMatch, emailMatch, url, pos = state.pos; |
|
|
|
|
|
|
|
if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; } |
|
|
|
|
|
|
@ -24,14 +24,18 @@ module.exports = function autolink(state) { |
|
|
|
if (linkMatch) { |
|
|
|
if (url_schemas.indexOf(linkMatch[1].toLowerCase()) < 0) { return false; } |
|
|
|
|
|
|
|
url = linkMatch[0].slice(1, -1); |
|
|
|
|
|
|
|
if (!state.parser.validateLink(url)) { return false; } |
|
|
|
|
|
|
|
state.push({ |
|
|
|
type: 'link_open', |
|
|
|
href: linkMatch[0].slice(1, -1), |
|
|
|
href: url, |
|
|
|
level: state.level |
|
|
|
}); |
|
|
|
state.push({ |
|
|
|
type: 'text', |
|
|
|
content: escapeHtml(linkMatch[0].slice(1, -1)), |
|
|
|
content: escapeHtml(url), |
|
|
|
level: state.level + 1 |
|
|
|
}); |
|
|
|
state.push({ type: 'link_close', level: state.level }); |
|
|
@ -43,14 +47,19 @@ module.exports = function autolink(state) { |
|
|
|
emailMatch = tail.match(EMAIL_RE); |
|
|
|
|
|
|
|
if (emailMatch) { |
|
|
|
|
|
|
|
url = emailMatch[0].slice(1, -1); |
|
|
|
|
|
|
|
if (!state.parser.validateLink('mailto:' + url)) { return false; } |
|
|
|
|
|
|
|
state.push({ |
|
|
|
type: 'link_open', |
|
|
|
href: 'mailto:' + emailMatch[0].slice(1, -1), |
|
|
|
href: 'mailto:' + url, |
|
|
|
level: state.level |
|
|
|
}); |
|
|
|
state.push({ |
|
|
|
type: 'text', |
|
|
|
content: escapeHtml(emailMatch[0].slice(1, -1)), |
|
|
|
content: escapeHtml(url), |
|
|
|
level: state.level + 1 |
|
|
|
}); |
|
|
|
state.push({ type: 'link_close', level: state.level }); |
|
|
|