diff --git a/lib/marked.js b/lib/marked.js index 1a472cf6..43e2802d 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -92,10 +92,10 @@ block.lexer = function(str) { // grab link definitons str = str.replace( /^ {0,3}\[([^\]]+)\]: *([^ ]+)(?: +"([^"]+)")? *(?:\n|$)/gm, - function(_, id, href, title) { + function(__, id, href, title) { links[id] = { href: href, - title: unquote(title) + title: title }; return ''; } @@ -241,8 +241,8 @@ var inline = { escape: /^\\([\\`*{}\[\]()#+\-.!])/, autolink: /^<([^ >]+(@|:\/)[^ >]+)>/, tag: /^<[^\n>]+>/, - link: /^!?\[([^\]]+)\]\(([^\)]+)\)/, - reflink: /^!?\[([^\]]+)\]\[([^\]]+)\]/, + link: /^!?\[([^\]]+)\] *\(([^\)]*)\)/, + reflink: /^!?\[([^\]]+)\] *\[([^\]]+)\]/, strong: /^__([\s\S]+?)__|^\*\*([\s\S]+?)\*\*/, em: /^_([^_]+)_|^\*([^*]+)\*/, code: /^`([^`]+)`|^``([\s\S]+?)``/ @@ -324,9 +324,10 @@ inline.lexer = function(str) { if (!link) throw new Error('Undefined Reference: ' + cap[2]); } else { + text = /^\s*([^\s]*)(?:\s+"([^"]+)")?\s*$/.exec(cap[2]); link = { - href: cap[2], - title: unquote(cap[3]) + href: text[1], + title: text[2] }; } out += '