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

Remove extra inner linebreak from code blocks #1266

Merged
merged 1 commit into from
May 11, 2018
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 lib/marked.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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