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 GFM Example 116 #1600

Merged
merged 1 commit into from
Feb 11, 2020
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
4 changes: 2 additions & 2 deletions src/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const {
const block = {
newline: /^\n+/,
code: /^( {4}[^\n]+\n*)+/,
fences: /^ {0,3}(`{3,}|~{3,})([^`~\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
Expand Down Expand Up @@ -72,7 +72,7 @@ block.paragraph = edit(block._paragraph)
.replace('heading', ' {0,3}#{1,6} +')
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
.replace('blockquote', ' {0,3}>')
.replace('fences', ' {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n')
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
Expand Down
3 changes: 1 addition & 2 deletions test/specs/commonmark/commonmark.0.29.json
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,7 @@
"example": 116,
"start_line": 1996,
"end_line": 2003,
"section": "Fenced code blocks",
"shouldFail": true
"section": "Fenced code blocks"
},
{
"markdown": "```\n``` aaa\n```\n",
Expand Down
3 changes: 1 addition & 2 deletions test/specs/gfm/commonmark.0.29.json
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,7 @@
"example": 116,
"start_line": 1996,
"end_line": 2003,
"section": "Fenced code blocks",
"shouldFail": true
"section": "Fenced code blocks"
},
{
"markdown": "```\n``` aaa\n```\n",
Expand Down
14 changes: 14 additions & 0 deletions test/specs/new/fences_breaking_paragraphs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<p>A paragraph</p>
<pre><code class="language-A">Here is code in
backtick fences</code></pre>
<p>B paragraph</p>
<pre><code class="language-B">Here is code in
tilde fences</code></pre>
<p>C paragraph</p>
<pre><code class="language-`C~">Alternative
tilde fences</code></pre>
<p>D paragraph ```~D` Invalid use of backtick fences</p>
<pre><code>
This will be read as
part of a codeblock
that ends with the file</code></pre>
27 changes: 27 additions & 0 deletions test/specs/new/fences_breaking_paragraphs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
A paragraph
```A
Here is code in
backtick fences
```

B paragraph
~~~B
Here is code in
tilde fences
~~~

C paragraph
~~~`C~
Alternative
tilde fences
~~~

D paragraph
```~D`
Invalid use of
backtick fences
```

This will be read as
part of a codeblock
that ends with the file