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