diff --git a/src/rules.js b/src/rules.js index 289c454304..6b29dfd0b0 100644 --- a/src/rules.js +++ b/src/rules.js @@ -27,7 +27,7 @@ export const block = { + ')', def: /^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/, table: noopTest, - lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/, + lheading: /^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, // regex template, placeholders will be replaced according to different paragraph // interruption rules of commonmark and the original markdown spec: _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, @@ -137,6 +137,7 @@ block.pedantic = merge({}, block.normal, { def: /^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: noopTest, // fences not supported + lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: edit(block.normal._paragraph) .replace('hr', block.hr) .replace('heading', ' *#{1,6} *[^\n]') diff --git a/test/specs/commonmark/commonmark.0.30.json b/test/specs/commonmark/commonmark.0.30.json index e8e3525f42..ef2859b3b9 100644 --- a/test/specs/commonmark/commonmark.0.30.json +++ b/test/specs/commonmark/commonmark.0.30.json @@ -647,8 +647,7 @@ "example": 81, "start_line": 1365, "end_line": 1372, - "section": "Setext headings", - "shouldFail": true + "section": "Setext headings" }, { "markdown": " Foo *bar\nbaz*\t\n====\n", @@ -656,8 +655,7 @@ "example": 82, "start_line": 1379, "end_line": 1386, - "section": "Setext headings", - "shouldFail": true + "section": "Setext headings" }, { "markdown": "Foo\n-------------------------\n\nFoo\n=\n", @@ -745,7 +743,8 @@ "example": 93, "start_line": 1531, "end_line": 1541, - "section": "Setext headings" + "section": "Setext headings", + "shouldFail": true }, { "markdown": "- Foo\n---\n", @@ -761,8 +760,7 @@ "example": 95, "start_line": 1559, "end_line": 1566, - "section": "Setext headings", - "shouldFail": true + "section": "Setext headings" }, { "markdown": "---\nFoo\n---\nBar\n---\nBaz\n", diff --git a/test/specs/gfm/commonmark.0.30.json b/test/specs/gfm/commonmark.0.30.json index 87fa81125e..5ff224f2c5 100644 --- a/test/specs/gfm/commonmark.0.30.json +++ b/test/specs/gfm/commonmark.0.30.json @@ -647,8 +647,7 @@ "example": 81, "start_line": 1365, "end_line": 1372, - "section": "Setext headings", - "shouldFail": true + "section": "Setext headings" }, { "markdown": " Foo *bar\nbaz*\t\n====\n", @@ -656,8 +655,7 @@ "example": 82, "start_line": 1379, "end_line": 1386, - "section": "Setext headings", - "shouldFail": true + "section": "Setext headings" }, { "markdown": "Foo\n-------------------------\n\nFoo\n=\n", @@ -745,7 +743,8 @@ "example": 93, "start_line": 1531, "end_line": 1541, - "section": "Setext headings" + "section": "Setext headings", + "shouldFail": true }, { "markdown": "- Foo\n---\n", @@ -761,8 +760,7 @@ "example": 95, "start_line": 1559, "end_line": 1566, - "section": "Setext headings", - "shouldFail": true + "section": "Setext headings" }, { "markdown": "---\nFoo\n---\nBar\n---\nBaz\n", diff --git a/test/unit/Lexer-spec.js b/test/unit/Lexer-spec.js index 8174d53139..7a1e826fd8 100644 --- a/test/unit/Lexer-spec.js +++ b/test/unit/Lexer-spec.js @@ -358,19 +358,6 @@ a | b ] }); }); - - it('after line break does not consume raw \n', () => { - expectTokens({ - md: 'T\nh\n---', - tokens: - jasmine.arrayContaining([ - jasmine.objectContaining({ - raw: 'T\nh\n' - }), - { type: 'hr', raw: '---' } - ]) - }); - }); }); describe('blockquote', () => {