|
|
@ -15,7 +15,7 @@ var autolinker = new Autolinker({ |
|
|
|
replaceFn: function (autolinker, match) { |
|
|
|
// Only collect matched strings but don't change anything.
|
|
|
|
if (match.getType() === 'url') { |
|
|
|
links.push(match.getUrl()); |
|
|
|
links.push({ text: match.matchedText, url: match.getUrl() }); |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
@ -75,9 +75,12 @@ module.exports = function linkify(t, state) { |
|
|
|
|
|
|
|
for (ln = 0; ln < links.length; ln++) { |
|
|
|
|
|
|
|
if (!state.parser.validateLink(links[ln])) { continue; } |
|
|
|
if (!state.parser.validateLink(links[ln].url)) { continue; } |
|
|
|
|
|
|
|
pos = text.indexOf(links[ln].text); |
|
|
|
|
|
|
|
if (pos === -1) { continue; } |
|
|
|
|
|
|
|
pos = text.indexOf(links[ln]); |
|
|
|
if (pos) { |
|
|
|
level = level; |
|
|
|
nodes.push({ |
|
|
@ -88,20 +91,20 @@ module.exports = function linkify(t, state) { |
|
|
|
} |
|
|
|
nodes.push({ |
|
|
|
type: 'link_open', |
|
|
|
href: links[ln], |
|
|
|
href: links[ln].url, |
|
|
|
title: '', |
|
|
|
level: level++ |
|
|
|
}); |
|
|
|
nodes.push({ |
|
|
|
type: 'text', |
|
|
|
content: escapeHtml(links[ln]), |
|
|
|
content: escapeHtml(links[ln].text), |
|
|
|
level: level |
|
|
|
}); |
|
|
|
nodes.push({ |
|
|
|
type: 'link_close', |
|
|
|
level: --level |
|
|
|
}); |
|
|
|
text = text.slice(pos + links[ln].length); |
|
|
|
text = text.slice(pos + links[ln].text.length); |
|
|
|
} |
|
|
|
if (text.length) { |
|
|
|
nodes.push({ |
|
|
|