|
|
@ -77,7 +77,7 @@ function parseLinkDestination(state, pos) { |
|
|
|
state.pos = pos + 1; |
|
|
|
return href; |
|
|
|
} |
|
|
|
if (code === 0x5C /* \ */) { |
|
|
|
if (code === 0x5C /* \ */ && pos + 1 < max) { |
|
|
|
pos++; |
|
|
|
href += state.src[pos++]; |
|
|
|
continue; |
|
|
@ -99,9 +99,9 @@ function parseLinkDestination(state, pos) { |
|
|
|
if (code === 0x20) { break; } |
|
|
|
|
|
|
|
// ascii control characters
|
|
|
|
if (code < 0x20 || code === 0x7F) { return null; } |
|
|
|
if (code < 0x20 || code === 0x7F) { break; } |
|
|
|
|
|
|
|
if (code === 0x5C /* \ */) { |
|
|
|
if (code === 0x5C /* \ */ && pos + 1 < max) { |
|
|
|
pos++; |
|
|
|
href += state.src[pos++]; |
|
|
|
continue; |
|
|
@ -109,14 +109,12 @@ function parseLinkDestination(state, pos) { |
|
|
|
|
|
|
|
if (code === 0x28 /* ( */) { |
|
|
|
level++; |
|
|
|
if (level > 1) { return null; } |
|
|
|
if (level > 1) { break; } |
|
|
|
} |
|
|
|
|
|
|
|
if (code === 0x29 /* ) */) { |
|
|
|
level--; |
|
|
|
if (level < 0) { |
|
|
|
break; |
|
|
|
} |
|
|
|
if (level < 0) { break; } |
|
|
|
} |
|
|
|
|
|
|
|
href += state.src[pos++]; |
|
|
@ -152,7 +150,7 @@ function parseLinkTitle(state, pos) { |
|
|
|
state.pos = pos + 1; |
|
|
|
return title; |
|
|
|
} |
|
|
|
if (code === 0x5C /* \ */) { |
|
|
|
if (code === 0x5C /* \ */ && pos + 1 < max) { |
|
|
|
pos++; |
|
|
|
title += state.src[pos++]; |
|
|
|
continue; |
|
|
@ -237,6 +235,7 @@ function links(state) { |
|
|
|
state.pos = labelStart - 1; |
|
|
|
return false; |
|
|
|
} |
|
|
|
pos++; |
|
|
|
} else { |
|
|
|
//
|
|
|
|
// Link reference
|
|
|
@ -252,7 +251,11 @@ function links(state) { |
|
|
|
if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) { |
|
|
|
start = pos + 1; |
|
|
|
pos = parseLinkLabel(state, pos); |
|
|
|
label = state.src.slice(start, pos); |
|
|
|
if (pos >= 0) { |
|
|
|
label = state.src.slice(start, pos++); |
|
|
|
} else { |
|
|
|
pos = start - 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// covers label === '' and label === undefined
|
|
|
@ -260,7 +263,10 @@ function links(state) { |
|
|
|
if (!label) { label = state.src.slice(labelStart, labelEnd); } |
|
|
|
|
|
|
|
ref = state.env.references[normalizeReference(label)]; |
|
|
|
if (!ref) { return false; } |
|
|
|
if (!ref) { |
|
|
|
state.pos = labelStart - 1; |
|
|
|
return false; |
|
|
|
} |
|
|
|
href = ref.href; |
|
|
|
title = ref.title; |
|
|
|
} |
|
|
@ -284,7 +290,7 @@ function links(state) { |
|
|
|
state.push({ type: 'link_close' }); |
|
|
|
} |
|
|
|
|
|
|
|
state.pos = pos + 1; |
|
|
|
state.pos = pos; |
|
|
|
state.posMax = max; |
|
|
|
return true; |
|
|
|
} |
|
|
|