better ref error handling
This commit is contained in:
parent
8d85d8352f
commit
cfe1617862
@ -323,10 +323,11 @@ inline.lexer = function(str) {
|
||||
break;
|
||||
case 'link':
|
||||
case 'reflink':
|
||||
if (cap[0][0] !== '!') {
|
||||
if (key === 'reflink') {
|
||||
link = links[cap[2]] || links[cap[1]];
|
||||
if (!link) {
|
||||
// apparently markdown says you're
|
||||
// supposed to do this ...?
|
||||
out += cap[0];
|
||||
break;
|
||||
}
|
||||
@ -339,6 +340,7 @@ inline.lexer = function(str) {
|
||||
title: text[2]
|
||||
};
|
||||
}
|
||||
if (cap[0][0] !== '!') {
|
||||
out += '<a href="'
|
||||
+ escape(link.href)
|
||||
+ '"'
|
||||
@ -351,17 +353,6 @@ inline.lexer = function(str) {
|
||||
+ inline.lexer(cap[1])
|
||||
+ '</a>';
|
||||
} else {
|
||||
if (key === 'reflink') {
|
||||
link = links[cap[2]];
|
||||
if (!link) throw new
|
||||
Error('Undefined Reference: ' + cap[2]);
|
||||
} else {
|
||||
text = /^\s*([^\s]*)(?:\s+"([^"]+)")?\s*$/.exec(cap[2]);
|
||||
link = {
|
||||
href: text[1],
|
||||
title: text[2]
|
||||
};
|
||||
}
|
||||
out += '<img src="'
|
||||
+ escape(link.href)
|
||||
+ '" alt="'
|
||||
|
Loading…
x
Reference in New Issue
Block a user