Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix paragraph type #1248

Merged
merged 4 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this test as well since it didn't really do anything. and was just there initially to have a test

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');
});
});