Merge branch 'text_blocks'

This commit is contained in:
Christopher Jeffrey 2011-10-04 19:39:56 -05:00
commit 783eede3ed

View File

@ -41,12 +41,9 @@ block.lexer = function(str) {
var tokens = []
, links = {};
// normalize whitespace
str = str.replace(/\r\n/g, '\n')
.replace(/\r/g, '\n')
str = str.replace(/\r\n|\r/g, '\n')
.replace(/\t/g, ' ');
// grab link definitons
str = str.replace(
/^ {0,3}\[([^\]]+)\]: *([^ ]+)(?: +"([^\n]+)")? *$/gm,
function(__, id, href, title) {
@ -380,52 +377,64 @@ var tok = function() {
+ '</code></pre>';
case 'blockquote_start':
var body = [];
while (next().type !== 'blockquote_end') {
body.push(tok());
}
return '<blockquote>'
+ body.join('')
+ '</blockquote>';
case 'list_start':
var body = []
, type = token.ordered ? 'ol' : 'ul';
var type = token.ordered ? 'ol' : 'ul'
, body = [];
while (next().type !== 'list_end') {
body.push(tok());
}
return '<' + type + '>'
+ body.join('')
+ '</' + type + '>';
case 'list_item_start':
var body = [];
while (next().type !== 'list_item_end') {
body.push(token.type === 'text'
? inline.lexer(token.text)
? text()
: tok());
}
return '<li>'
+ body.join(' ')
+ '</li>';
case 'loose_item_start':
var body = [];
while (next().type !== 'list_item_end') {
body.push(tok());
}
return '<li>'
+ body.join(' ')
+ '</li>';
case 'html':
return inline.lexer(token.text);
case 'text':
return '<p>' + text() + '</p>';
}
};
var text = function() {
var body = [ token.text ]
, top;
while ((top = tokens[tokens.length-1])
&& top.type === 'text') {
body.push(next().text);
}
return '<p>'
+ inline.lexer(body.join('\n'))
+ '</p>';
}
return inline.lexer(body.join('\n'));
};
var parse = function(src) {