|
|
@ -7,7 +7,6 @@ |
|
|
|
|
|
|
|
var arrayReplaceAt = require('../common/utils').arrayReplaceAt; |
|
|
|
var normalizeLink = require('../common/utils').normalizeLink; |
|
|
|
var Token = require('../token'); |
|
|
|
|
|
|
|
|
|
|
|
function isLinkOpen(str) { |
|
|
@ -77,30 +76,30 @@ module.exports = function linkify(state) { |
|
|
|
pos = links[ln].index; |
|
|
|
|
|
|
|
if (pos > lastPos) { |
|
|
|
token = new Token('text', '', 0); |
|
|
|
token = new state.Token('text', '', 0); |
|
|
|
token.content = text.slice(lastPos, pos); |
|
|
|
token.level = level; |
|
|
|
nodes.push(token); |
|
|
|
} |
|
|
|
|
|
|
|
token = new Token('link_open', 'a', 1); |
|
|
|
token = new state.Token('link_open', 'a', 1); |
|
|
|
token.attrs = [ [ 'href', normalizeLink(links[ln].url) ] ]; |
|
|
|
token.level = level++; |
|
|
|
nodes.push(token); |
|
|
|
|
|
|
|
token = new Token('text', '', 0); |
|
|
|
token = new state.Token('text', '', 0); |
|
|
|
token.content = links[ln].text; |
|
|
|
token.level = level; |
|
|
|
nodes.push(token); |
|
|
|
|
|
|
|
token = new Token('link_close', 'a', -1); |
|
|
|
token = new state.Token('link_close', 'a', -1); |
|
|
|
token.level = --level; |
|
|
|
nodes.push(token); |
|
|
|
|
|
|
|
lastPos = links[ln].lastIndex; |
|
|
|
} |
|
|
|
if (lastPos < text.length) { |
|
|
|
token = new Token('text', '', 0); |
|
|
|
token = new state.Token('text', '', 0); |
|
|
|
token.content = text.slice(lastPos); |
|
|
|
token.level = level; |
|
|
|
nodes.push(token); |
|
|
|