rename block rule to code

This commit is contained in:
Christopher Jeffrey 2011-10-22 08:05:31 -05:00
parent 21d0acf145
commit 9ff55ae9d7

View File

@ -11,7 +11,7 @@
var block = { var block = {
newline: /^\n+/, newline: /^\n+/,
block: /^ {4,}[^\n]*(?:\n {4,}[^\n]*|\n)*(?=\n| *$)/, code: /^ {4,}[^\n]*(?:\n {4,}[^\n]*|\n)*(?=\n| *$)/,
hr: /^( *[\-*_]){3,} *\n/, hr: /^( *[\-*_]){3,} *\n/,
heading: /^ *(#{1,6}) *([^\0]+?) *#* *\n+/, heading: /^ *(#{1,6}) *([^\0]+?) *#* *\n+/,
lheading: /^([^\n]+)\n *(=|-){3,}/, lheading: /^([^\n]+)\n *(=|-){3,}/,
@ -68,11 +68,11 @@ block.token = function(str, tokens) {
continue; continue;
} }
if (cap = block.block.exec(str)) { if (cap = block.code.exec(str)) {
str = str.substring(cap[0].length); str = str.substring(cap[0].length);
cap = cap[0].replace(/^ {4}/gm, ''); cap = cap[0].replace(/^ {4}/gm, '');
tokens.push({ tokens.push({
type: 'block', type: 'code',
text: cap text: cap
}); });
continue; continue;
@ -256,7 +256,9 @@ inline.lexer = function(str) {
text = escape(cap[1]); text = escape(cap[1]);
href = text; href = text;
} }
out += '<a href="' + href + '">' out += '<a href="'
+ href
+ '">'
+ text + text
+ '</a>'; + '</a>';
continue; continue;
@ -392,7 +394,7 @@ var tok = function() {
+ '>'; + '>';
} }
case 'block': { case 'code': {
return '<pre><code>' return '<pre><code>'
+ escape(token.text) + escape(token.text)
+ '</code></pre>'; + '</code></pre>';