Skip to content

Commit 1f96816

Browse files
authored
Merge pull request #1600 from calculuschild/Fix-Example-116
Fix GFM Example 116
2 parents 5ebb8fc + 63454d2 commit 1f96816

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed

src/rules.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const {
1010
const block = {
1111
newline: /^\n+/,
1212
code: /^( {4}[^\n]+\n*)+/,
13-
fences: /^ {0,3}(`{3,}|~{3,})([^`~\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
13+
fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
1414
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
1515
heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,
1616
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
@@ -72,7 +72,7 @@ block.paragraph = edit(block._paragraph)
7272
.replace('heading', ' {0,3}#{1,6} +')
7373
.replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
7474
.replace('blockquote', ' {0,3}>')
75-
.replace('fences', ' {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n')
75+
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
7676
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
7777
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)')
7878
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks

test/specs/commonmark/commonmark.0.29.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,8 +930,7 @@
930930
"example": 116,
931931
"start_line": 1996,
932932
"end_line": 2003,
933-
"section": "Fenced code blocks",
934-
"shouldFail": true
933+
"section": "Fenced code blocks"
935934
},
936935
{
937936
"markdown": "```\n``` aaa\n```\n",

test/specs/gfm/commonmark.0.29.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -930,8 +930,7 @@
930930
"example": 116,
931931
"start_line": 1996,
932932
"end_line": 2003,
933-
"section": "Fenced code blocks",
934-
"shouldFail": true
933+
"section": "Fenced code blocks"
935934
},
936935
{
937936
"markdown": "```\n``` aaa\n```\n",
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<p>A paragraph</p>
2+
<pre><code class="language-A">Here is code in
3+
backtick fences</code></pre>
4+
<p>B paragraph</p>
5+
<pre><code class="language-B">Here is code in
6+
tilde fences</code></pre>
7+
<p>C paragraph</p>
8+
<pre><code class="language-`C~">Alternative
9+
tilde fences</code></pre>
10+
<p>D paragraph ```~D` Invalid use of backtick fences</p>
11+
<pre><code>
12+
This will be read as
13+
part of a codeblock
14+
that ends with the file</code></pre>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
A paragraph
2+
```A
3+
Here is code in
4+
backtick fences
5+
```
6+
7+
B paragraph
8+
~~~B
9+
Here is code in
10+
tilde fences
11+
~~~
12+
13+
C paragraph
14+
~~~`C~
15+
Alternative
16+
tilde fences
17+
~~~
18+
19+
D paragraph
20+
```~D`
21+
Invalid use of
22+
backtick fences
23+
```
24+
25+
This will be read as
26+
part of a codeblock
27+
that ends with the file

0 commit comments

Comments
 (0)