diff --git a/lib/marked.js b/lib/marked.js index 05be0b5dfc..2b40cfaf41 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -33,7 +33,7 @@ var block = { def: /^ {0,3}\[(label)\]: *\n? *]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/, table: noop, lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/, - paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)+)/, + paragraph: /^([^\n]+(?:\n?(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)+)/, text: /^[^\n]+/ }; diff --git a/test/unit/marked-spec.js b/test/unit/marked-spec.js index 0bb5b39f6d..97789afe09 100644 --- a/test/unit/marked-spec.js +++ b/test/unit/marked-spec.js @@ -1,11 +1,5 @@ var marked = require('../../lib/marked.js'); -it('should run the test', function () { - spyOn(marked, 'parse').and.callThrough(); - marked.parse('Hello World!'); - expect(marked.parse).toHaveBeenCalled(); -}); - describe('Test heading ID functionality', function() { it('should add id attribute by default', function() { var renderer = new marked.Renderer(marked.defaults); @@ -19,3 +13,15 @@ describe('Test heading ID functionality', function() { expect(header).toBe('

test

\n'); }); }); + +describe('Test paragraph token type', function () { + it('should use the "paragraph" type on top level', function () { + const md = 'A Paragraph.\n\n> A blockquote\n\n- list item\n'; + + const tokens = marked.lexer(md); + + expect(tokens[0].type).toBe('paragraph'); + expect(tokens[3].type).toBe('paragraph'); + expect(tokens[7].type).toBe('text'); + }); +});