Skip to content

Commit

Permalink
Merge pull request #1266 from remyrylan/remove-extra-linebreak
Browse files Browse the repository at this point in the history
Remove extra inner linebreak from code blocks
  • Loading branch information
styfle committed May 11, 2018
2 parents 579f7bf + 6ab2593 commit 0218945
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/marked.js
Expand Up @@ -889,15 +889,15 @@ Renderer.prototype.code = function(code, lang, escaped) {
if (!lang) {
return '<pre><code>'
+ (escaped ? code : escape(code, true))
+ '\n</code></pre>';
+ '</code></pre>';
}

return '<pre><code class="'
+ this.options.langPrefix
+ escape(lang, true)
+ '">'
+ (escaped ? code : escape(code, true))
+ '\n</code></pre>\n';
+ '</code></pre>\n';
};

Renderer.prototype.blockquote = function(quote) {
Expand Down
18 changes: 6 additions & 12 deletions test/new/cm_blockquotes.html
Expand Up @@ -32,8 +32,7 @@ <h3 id="example-194">Example 194</h3>

<pre><code>&gt; # Foo
&gt; bar
&gt; baz
</code></pre>
&gt; baz</code></pre>

<h3 id="example-195">Example 195</h3>

Expand Down Expand Up @@ -78,11 +77,9 @@ <h3 id="example-199">Example 199</h3>
<p>For the same reason, we can’t omit the <code>&gt;</code> in front of subsequent lines of an indented or fenced code block:</p>

<blockquote>
<pre><code>foo
</code></pre>
<pre><code>foo</code></pre>
</blockquote>
<pre><code>bar
</code></pre>
<pre><code>bar</code></pre>

<h3 id="example-200">Example 200</h3>

Expand All @@ -94,8 +91,7 @@ <h3 id="example-200">Example 200</h3>
&lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;foo&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;
</code></pre>
&lt;pre&gt;&lt;code&gt;&lt;/code&gt;&lt;/pre&gt;</code></pre>

<h3 id="example-201">Example 201</h3>
<pre><code>&gt; foo
Expand All @@ -104,8 +100,7 @@ <h3 id="example-201">Example 201</h3>
&lt;blockquote&gt;
&lt;p&gt;foo
- bar&lt;/p&gt;
&lt;/blockquote&gt;
</code></pre>
&lt;/blockquote&gt;</code></pre>

<h3 id="example-202">Example 202</h3>

Expand Down Expand Up @@ -231,8 +226,7 @@ <h3 id="example-215">Example 215</h3>
<p>When including an indented code block in a block quote, remember that the block quote marker includes both the <code>&gt;</code> and a following space. So five spaces are needed after the <code>&gt;</code>:</p>

<blockquote>
<pre><code>code
</code></pre>
<pre><code>code</code></pre>
</blockquote>
<blockquote>
<p>not code</p>
Expand Down

0 comments on commit 0218945

Please sign in to comment.