Skip to content

Commit

Permalink
fix(double linebreaks): fix double linebreaks in html output
Browse files Browse the repository at this point in the history
Closes #291
  • Loading branch information
tivie committed Sep 28, 2016
1 parent fe64a17 commit f97e072
Show file tree
Hide file tree
Showing 93 changed files with 14 additions and 296 deletions.
8 changes: 4 additions & 4 deletions dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/subParsers/lists.js
Expand Up @@ -112,7 +112,7 @@ showdown.subParser('lists', function (text, options, globals) {
var pos = txt.search(counterRxg);
if (pos !== -1) {
// slice
result += '\n\n<' + listType + '>' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>\n\n';
result += '\n<' + listType + '>' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>\n';

// invert counterType and listType
listType = (listType === 'ul') ? 'ol' : 'ul';
Expand All @@ -121,14 +121,14 @@ showdown.subParser('lists', function (text, options, globals) {
//recurse
parseCL(txt.slice(pos));
} else {
result += '\n\n<' + listType + '>' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n\n';
result += '\n<' + listType + '>' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n';
}
})(list);
for (var i = 0; i < subLists.length; ++i) {

}
} else {
result = '\n\n<' + listType + '>' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n\n';
result = '\n<' + listType + '>' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n';
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion src/subParsers/paragraphs.js
Expand Up @@ -58,7 +58,7 @@ showdown.subParser('paragraphs', function (text, options, globals) {
}
grafsOut[i] = grafsOutIt;
}
text = grafsOut.join('\n\n');
text = grafsOut.join('\n');
// Strip leading and trailing lines:
text = text.replace(/^\n+/g, '');
text = text.replace(/\n+$/g, '');
Expand Down
3 changes: 0 additions & 3 deletions test/cases/blockquote-followed-by-code.html
Expand Up @@ -2,12 +2,9 @@
<p>a blockquote
with a 4 space indented line (not code)</p>
</blockquote>

<p>sep</p>

<blockquote>
<p>a blockquote</p>
</blockquote>

<pre><code>with some code after
</code></pre>
2 changes: 0 additions & 2 deletions test/cases/blockquote-inside-code.html
@@ -1,9 +1,7 @@
<pre><code>&gt; this is a pseudo blockquote
&gt; inside a code block
</code></pre>

<p>foo</p>

<pre><code>&gt; this is another bq
inside code
</code></pre>
3 changes: 0 additions & 3 deletions test/cases/blockquote-nested-markdown.html
@@ -1,14 +1,11 @@
<blockquote>
<h2 id="thisisaheader">This is a header.</h2>

<ol>
<li>This is the first list item.</li>

<li>This is the second list item.</li>
</ol>

<p>Here's some example code:</p>

<pre><code>return shell_exec("echo $input | $markdown_script");
</code></pre>
</blockquote>
1 change: 0 additions & 1 deletion test/cases/blockquote.html
@@ -1,5 +1,4 @@
<blockquote>
<p>This is a multi line blockquote test</p>

<p>With more than one line.</p>
</blockquote>
1 change: 0 additions & 1 deletion test/cases/code-block-html-escape.html
@@ -1,4 +1,3 @@
<p>This is some HTML:</p>

<pre><code>&lt;h1&gt;Heading&lt;/h1&gt;
</code></pre>
1 change: 0 additions & 1 deletion test/cases/code-block.html
@@ -1,4 +1,3 @@
<p>This is a normal paragraph:</p>

<pre><code>This is a code block.
</code></pre>
32 changes: 0 additions & 32 deletions test/cases/emphasis.html
@@ -1,66 +1,34 @@
<p><em>single asterisks</em></p>

<p><em>single underscores</em></p>

<p><strong>double asterisks</strong></p>

<p><strong>double underscores</strong></p>

<p>text <em>with italic sentence</em> in middle</p>

<p>text <strong>with bold sentence</strong> in middle</p>

<p>text with <strong>bold text that
spans across multiple</strong> lines</p>

<p>underscored_word</p>

<p>doubleunderscore__word</p>

<p>asterix*word</p>

<p>doubleasterix**word</p>

<p>line with_underscored word</p>

<p>line with__doubleunderscored word</p>

<p>line with*asterixed word</p>

<p>line with**doubleasterixed word</p>

<p>some line<em>with</em>inner underscores</p>

<p>some line<strong>with</strong>inner double underscores</p>

<p>some line<em>with</em>inner asterixs</p>

<p>some line<strong>with</strong>inner double asterixs</p>

<p>another line with just _one underscore</p>

<p>another line with just __one double underscore</p>

<p>another line with just *one asterix</p>

<p>another line with just **one double asterix</p>

<p>a sentence with<em>underscore and another</em>underscore</p>

<p>a sentence with<strong>doubleunderscore and another</strong>doubleunderscore</p>

<p>a sentence with<em>asterix and another</em>asterix</p>

<p>a sentence with<strong>doubleasterix and another</strong>doubleasterix</p>

<p>escaped word_with_underscores</p>

<p>escaped word__with__double underscores</p>

<p>escaped word<em>_with_</em>single italic underscore</p>

<p>escaped word*with*asterixs</p>

<p>escaped word**with**asterixs</p>

<p>escaped word<strong>*with*</strong>bold asterixs</p>
15 changes: 0 additions & 15 deletions test/cases/escaping.html
@@ -1,31 +1,16 @@
<p>These should all be escaped:</p>

<p>\</p>

<p>`</p>

<p>*</p>

<p>_</p>

<p>{</p>

<p>}</p>

<p>[</p>

<p>]</p>

<p>(</p>

<p>)</p>

<p>#</p>

<p>+</p>

<p>-</p>

<p>.</p>

<p>!</p>
1 change: 0 additions & 1 deletion test/cases/github-style-at-start.html
Expand Up @@ -2,5 +2,4 @@
// ...
}
</code></pre>

<p>That is some code!</p>
3 changes: 0 additions & 3 deletions test/cases/github-style-codeblock-inside-quote.html
@@ -1,14 +1,11 @@
<blockquote>
<p>Define a function in javascript:</p>

<pre><code>function MyFunc(a) {
var s = '`';
}
</code></pre>

<blockquote>
<p>And some nested quote</p>

<pre><code class="html language-html">&lt;div&gt;HTML!&lt;/div&gt;
</code></pre>
</blockquote>
Expand Down
3 changes: 0 additions & 3 deletions test/cases/github-style-codeblock.html
@@ -1,11 +1,8 @@
<p>Define a function in javascript:</p>

<pre><code>function MyFunc(a) {
var s = '`';
}
</code></pre>

<p>And some HTML</p>

<pre><code class="html language-html">&lt;div&gt;HTML!&lt;/div&gt;
</code></pre>
4 changes: 0 additions & 4 deletions test/cases/horizontal-rules.html
@@ -1,9 +1,5 @@
<hr />

<hr />

<hr />

<hr />

<hr />
6 changes: 0 additions & 6 deletions test/cases/html-comments.html
@@ -1,14 +1,8 @@
<!-- a comment -->

<!-- a comment with *bogus* __markdown__ inside -->

<p>words <!-- a comment --> words</p>

<!-- comment -->

<p>words</p>

<!-- comment -->

<pre><code>&lt;!-- comment --&gt;
</code></pre>
1 change: 0 additions & 1 deletion test/cases/html-inside-listed-code.html
@@ -1,6 +1,5 @@
<ul>
<li><p>list item 1</p>

<pre><code class="html language-html">&lt;a href="www.google.com"&gt;google&lt;/a&gt;
&lt;div&gt;
&lt;div&gt;some div&lt;/div&gt;
Expand Down
18 changes: 0 additions & 18 deletions test/cases/html5-strutural-tags.html
@@ -1,26 +1,16 @@
<p>These HTML5 tags should pass through just fine.</p>

<section>hello</section>

<header>head</header>

<footer>footsies</footer>

<nav>navigation</nav>

<article>read me</article>

<aside>ignore me</aside>

<article>read
me</article>

<aside>
ignore me
</aside>

<p>the end</p>

<table class="test">
<tr>
<td>Foo</td>
Expand All @@ -29,7 +19,6 @@
<td>Bar</td>
</tr>
</table>

<table class="test">
<thead>
<tr>
Expand All @@ -45,31 +34,24 @@
</tr>
</tfoot>
</table>

<audio class="podcastplayer" controls>
<source src="foobar.mp3" type="audio/mp3" preload="none"></source>
<source src="foobar.off" type="audio/ogg" preload="none"></source>
</audio>

<video src="foo.ogg">
<track kind="subtitles" src="foo.en.vtt" srclang="en" label="English">
<track kind="subtitles" src="foo.sv.vtt" srclang="sv" label="Svenska">
</video>

<address>My street</address>

<canvas id="canvas" width="300" height="300">
Sorry, your browser doesn't support the &lt;canvas&gt; element.
</canvas>

<figure>
<img src="mypic.png" alt="An awesome picture">
<figcaption>Caption for the awesome picture</figcaption>
</figure>

<hgroup>
<h1>Main title</h1>
<h2>Secondary title</h2>
</hgroup>

<output name="result"></output>
2 changes: 0 additions & 2 deletions test/cases/images.html
@@ -1,5 +1,3 @@
<p><img src="/path/to/img.jpg" alt="Alt text" /></p>

<p><img src="/path/to/img.jpg" alt="Alt text" title="Optional title" /></p>

<p><img src="url/to/image" alt="Alt text" title="Optional title attribute" /></p>
1 change: 0 additions & 1 deletion test/cases/inline-anchors.html
@@ -1,3 +1,2 @@
<p>This is <a href="http://example.com/" title="Title">an example</a> inline link.</p>

<p><a href="http://example.net/">This link</a> has no title attribute.</p>
5 changes: 0 additions & 5 deletions test/cases/inline-code.html
@@ -1,11 +1,6 @@
<p>Create a new <code>function</code>.</p>

<p>Use the backtick in MySQL syntax <code>SELECT `column` FROM whatever</code>.</p>

<p>A single backtick in a code span: <code>`</code></p>

<p>A backtick-delimited string in a code span: <code>`foo`</code></p>

<p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>

<p><code>&amp;#8212;</code> is the decimal-encoded equivalent of <code>&amp;mdash;</code>.</p>
1 change: 0 additions & 1 deletion test/cases/inline-style-tag.html
@@ -1,5 +1,4 @@
<style>
p { line-height: 20px; }
</style>

<p>An exciting sentence.</p>
1 change: 0 additions & 1 deletion test/cases/lazy-blockquote.html
@@ -1,5 +1,4 @@
<blockquote>
<p>This is a multi line blockquote test</p>

<p>With more than one line.</p>
</blockquote>
1 change: 0 additions & 1 deletion test/cases/line-starts-with-html.html
@@ -1,3 +1,2 @@
<p><a href="foo">some text</a> words</p>

<p><br> words</p>

0 comments on commit f97e072

Please sign in to comment.