add paragraph token, fix paragraph rule

This commit is contained in:
Christopher Jeffrey 2012-01-03 14:16:31 -06:00
parent 75bf7ec7ed
commit 73113644cb

View File

@ -45,6 +45,16 @@ block.paragraph = (function() {
body = body.join('|');
return new
RegExp('^([^\\n]+\\n?(?!' + body + '))+\\n*');
return new
RegExp('^([^\\n]+\\n(?!'
+ body
+ '))+\\n|^([^\\0](?!\\n(?:'
+ body
+ ')))*$');
return new
RegExp('^([^\\n]+\\n(?!' + body + '))+\\n*|^[^\\0]*$');
})();
@ -230,15 +240,10 @@ block.token = function(str, tokens, top) {
// top-level text
if (top && (cap = block.paragraph.exec(str))) {
str = str.substring(cap[0].length);
// possibly switch to
// a "paragraph" token
tokens.push({
type: 'text',
type: 'paragraph',
text: cap[0]
});
tokens.push({
type: 'space'
});
continue;
}
@ -548,6 +553,11 @@ var tok = function() {
case 'html': {
return inline.lexer(token.text);
}
case 'paragraph': {
return '<p>'
+ inline.lexer(token.text)
+ '</p>';
}
case 'text': {
return '<p>'
+ text()