diff --git a/lib/marked.js b/lib/marked.js index afd50197..d47ffec5 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -368,60 +368,95 @@ var next = function() { var tok = function() { switch (token.type) { - case 'space': + case 'space': { return ''; - case 'hr': + } + + case 'hr': { return '
'; - case 'heading': - return '' + } + + case 'heading': { + return '' + inline.lexer(token.text) - + ''; - case 'block': + + ''; + } + + case 'block': { return '
'
         + escape(token.text)
         + '
'; - case 'blockquote_start': + } + + case 'blockquote_start': { var body = []; + while (next().type !== 'blockquote_end') { body.push(tok()); } + return '
' + body.join('') + '
'; - case 'list_start': + } + + case 'list_start': { var type = token.ordered ? 'ol' : 'ul' , body = []; + while (next().type !== 'list_end') { body.push(tok()); } - return '<' + type + '>' + + return '<' + + type + + '>' + body.join('') - + ''; - case 'list_item_start': + + ''; + } + + case 'list_item_start': { var body = []; + while (next().type !== 'list_item_end') { body.push(token.type === 'text' ? text() : tok()); } + return '
  • ' + body.join(' ') + '
  • '; - case 'loose_item_start': + } + + case 'loose_item_start': { var body = []; + while (next().type !== 'list_item_end') { body.push(tok()); } + return '
  • ' + body.join(' ') + '
  • '; - case 'html': + } + + case 'html': { return inline.lexer(token.text); - case 'text': + } + + case 'text': { return '

    ' + text() + '

    '; - } + } + } }; var text = function() {