Skip to content

Commit

Permalink
require closing fence to be on a new line (fix markedjs#1058), while …
Browse files Browse the repository at this point in the history
…still allowing empty code blocks
  • Loading branch information
Feder1co5oave committed Dec 8, 2018
1 parent 86214bb commit 67a5941
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ block.normal = merge({}, block);
*/

block.gfm = merge({}, block.normal, {
fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,
fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n(?:|([\s\S]*?)\n) *\1 *(?:\n+|$)/,
paragraph: /^/,
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
});
Expand Down
5 changes: 5 additions & 0 deletions test/new/gfm_code.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@


</code></pre>

<p>Closing fences must lay on a new line:</p>
<pre><code>hello()
^```
&quot;this should still be in the code block!&quot;</code></pre>
8 changes: 8 additions & 0 deletions test/new/gfm_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ ciao
```

Closing fences must lay on a new line:

```
hello()
^```
"this should still be in the code block!"
```

0 comments on commit 67a5941

Please sign in to comment.