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