Skip to content

Commit

Permalink
Merge pull request #1011 from Feder1co5oave/fix-645
Browse files Browse the repository at this point in the history
Preserve trailing newlines in code fences
  • Loading branch information
joshbruce authored Jan 12, 2018
2 parents 3175599 + 2c11624 commit 3668af8
Show file tree
Hide file tree
Showing 3 changed files with 15 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 @@ -76,7 +76,7 @@ block.normal = merge({}, block);
*/

block.gfm = merge({}, block.normal, {
fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,
fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\n? *\1 *(?:\n+|$)/,
paragraph: /^/,
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
});
Expand Down
6 changes: 6 additions & 0 deletions test/new/gfm_code.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
<p>How about a code block with only an empty line?</p>
<pre><code class="lang-js">
</code></pre>

<p>With some trailing empty lines:</p>
<pre><code>ciao


</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 @@ -24,4 +24,12 @@ How about a code block with only an empty line?

```js

```

With some trailing empty lines:

```
ciao
```

0 comments on commit 3668af8

Please sign in to comment.