diff --git a/lib/marked.js b/lib/marked.js index 87929841..e83b2a29 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -22,12 +22,19 @@ var block = { blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/, list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/, html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/, - def: /^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/, + def: /^ {0,3}\[(label)\]: *\n? *]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/, table: noop, paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/, text: /^[^\n]+/ }; +block._label = /(?:\[[^\]]*\]|\\[\[\]]|[^\\\[\]])+/; +block._title = /(?:"(?:\\"|[^"])*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/; +block.def = replace(block.def) + ('label', block._label) + ('title', block._title) + (); + block.bullet = /(?:[*+-]|\d+\.)/; block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/; block.item = replace(block.item, 'gm') @@ -371,6 +378,7 @@ Lexer.prototype.token = function(src, top, bq) { // def if ((!bq && top) && (cap = this.rules.def.exec(src))) { src = src.substring(cap[0].length); + if (cap[3]) cap[3] = cap[3].substring(1,cap[3].length-1); this.tokens.links[cap[1].toLowerCase()] = { href: cap[2], title: cap[3]