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