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