Skip to content

Commit

Permalink
Merge pull request #1248 from UziTech/paragraph-type
Browse files Browse the repository at this point in the history
fix paragraph type
  • Loading branch information
joshbruce committed May 2, 2018
2 parents 37c0324 + 484deb5 commit 41a8cad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var block = {
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\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]+/
};

Expand Down
18 changes: 12 additions & 6 deletions test/unit/marked-spec.js
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -19,3 +13,15 @@ describe('Test heading ID functionality', function() {
expect(header).toBe('<h1>test</h1>\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');
});
});

0 comments on commit 41a8cad

Please sign in to comment.