|
|
@ -2,9 +2,6 @@ |
|
|
|
|
|
|
|
'use strict'; |
|
|
|
|
|
|
|
var parseLinkLabel = require('../helpers/parse_link_label'); |
|
|
|
var parseLinkDestination = require('../helpers/parse_link_destination'); |
|
|
|
var parseLinkTitle = require('../helpers/parse_link_title'); |
|
|
|
var normalizeReference = require('../common/utils').normalizeReference; |
|
|
|
var isSpace = require('../common/utils').isSpace; |
|
|
|
|
|
|
@ -31,7 +28,7 @@ module.exports = function image(state, silent) { |
|
|
|
if (state.src.charCodeAt(state.pos + 1) !== 0x5B/* [ */) { return false; } |
|
|
|
|
|
|
|
labelStart = state.pos + 2; |
|
|
|
labelEnd = parseLinkLabel(state, state.pos + 1, false); |
|
|
|
labelEnd = state.md.helpers.parseLinkLabel(state, state.pos + 1, false); |
|
|
|
|
|
|
|
// parser failed to find ']', so it's not a valid link
|
|
|
|
if (labelEnd < 0) { return false; } |
|
|
@ -54,7 +51,7 @@ module.exports = function image(state, silent) { |
|
|
|
// [link]( <href> "title" )
|
|
|
|
// ^^^^^^ parsing link destination
|
|
|
|
start = pos; |
|
|
|
res = parseLinkDestination(state.src, pos, state.posMax); |
|
|
|
res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax); |
|
|
|
if (res.ok) { |
|
|
|
href = state.md.normalizeLink(res.str); |
|
|
|
if (state.md.validateLink(href)) { |
|
|
@ -74,7 +71,7 @@ module.exports = function image(state, silent) { |
|
|
|
|
|
|
|
// [link]( <href> "title" )
|
|
|
|
// ^^^^^^^ parsing link title
|
|
|
|
res = parseLinkTitle(state.src, pos, state.posMax); |
|
|
|
res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax); |
|
|
|
if (pos < max && start !== pos && res.ok) { |
|
|
|
title = res.str; |
|
|
|
pos = res.pos; |
|
|
@ -102,7 +99,7 @@ module.exports = function image(state, silent) { |
|
|
|
|
|
|
|
if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) { |
|
|
|
start = pos + 1; |
|
|
|
pos = parseLinkLabel(state, pos); |
|
|
|
pos = state.md.helpers.parseLinkLabel(state, pos); |
|
|
|
if (pos >= 0) { |
|
|
|
label = state.src.slice(start, pos++); |
|
|
|
} else { |
|
|
|