Skip to content

Commit

Permalink
fix(lists linebreaks): fix lists linebreaks in html output
Browse files Browse the repository at this point in the history
Closes #291
  • Loading branch information
tivie committed Sep 29, 2016
1 parent f97e072 commit 2b813cd
Show file tree
Hide file tree
Showing 39 changed files with 19 additions and 80 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.

8 changes: 4 additions & 4 deletions src/subParsers/lists.js
Expand Up @@ -77,7 +77,7 @@ showdown.subParser('lists', function (text, options, globals) {
item = showdown.subParser('spanGamut')(item, options, globals);
}
}
item = '\n<li' + bulletStyle + '>' + item + '</li>\n';
item = '<li' + bulletStyle + '>' + item + '</li>\n';
return item;
});

Expand Down Expand Up @@ -112,7 +112,7 @@ showdown.subParser('lists', function (text, options, globals) {
var pos = txt.search(counterRxg);
if (pos !== -1) {
// slice
result += '\n<' + listType + '>' + processListItems(txt.slice(0, pos), !!trimTrailing) + '</' + listType + '>\n';
result += '\n<' + listType + '>\n' + 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<' + listType + '>' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n';
result += '\n<' + listType + '>\n' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n';
}
})(list);
for (var i = 0; i < subLists.length; ++i) {

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

return result;
Expand Down
1 change: 0 additions & 1 deletion test/cases/blockquote-nested-markdown.html
Expand Up @@ -2,7 +2,6 @@
<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>
Expand Down
1 change: 0 additions & 1 deletion test/cases/doubline-list.html
@@ -1,5 +1,4 @@
<ul>
<li><p>Bird</p></li>

<li><p>Magic</p></li>
</ul>
2 changes: 0 additions & 2 deletions test/cases/list-followed-by-blockquote.html
@@ -1,14 +1,12 @@
<h1 id="sometitle">some title</h1>
<ol>
<li>list item 1</li>

<li>list item 2</li>
</ol>
<blockquote>
<p>some text in a blockquote</p>
</blockquote>
<ul>
<li>another list item 1</li>

<li>another list item 2</li>
</ul>
2 changes: 0 additions & 2 deletions test/cases/list-followed-by-ghcode.html
@@ -1,7 +1,6 @@
<h1 id="sometitle">some title</h1>
<ol>
<li>list item 1</li>

<li>list item 2</li>
</ol>
<pre><code>some code
Expand All @@ -10,6 +9,5 @@ <h1 id="sometitle">some title</h1>
</code></pre>
<ul>
<li>another list item 1</li>

<li>another list item 2</li>
</ul>
1 change: 0 additions & 1 deletion test/cases/multi-paragraph-list.html
@@ -1,6 +1,5 @@
<ol>
<li><p>This is a major bullet point.</p>
<p>That contains multiple paragraphs.</p></li>

<li><p>And another line</p></li>
</ol>
1 change: 0 additions & 1 deletion test/cases/multiline-unordered-list.html
@@ -1,6 +1,5 @@
<ul>
<li>This line spans
more than one line and is lazy</li>

<li>Similar to this line</li>
</ul>
2 changes: 0 additions & 2 deletions test/cases/ordered-list-same-number.html
@@ -1,7 +1,5 @@
<ol>
<li>Red</li>

<li>Green</li>

<li>Blue</li>
</ol>
2 changes: 0 additions & 2 deletions test/cases/ordered-list-wrong-numbers.html
@@ -1,7 +1,5 @@
<ol>
<li>Red</li>

<li>Green</li>

<li>Blue</li>
</ol>
2 changes: 0 additions & 2 deletions test/cases/ordered-list.html
@@ -1,7 +1,5 @@
<ol>
<li>Red</li>

<li>Green</li>

<li>Blue</li>
</ol>
4 changes: 0 additions & 4 deletions test/cases/paragraphed-list-with-sublists.html
Expand Up @@ -2,14 +2,10 @@
<li><p>foo</p>
<ul>
<li><p>bazinga</p></li>

<li><p>yeah</p></li></ul></li>

<li><p>bar</p>
<ol>
<li><p>damn</p></li>

<li><p>so many paragraphs</p></li></ol></li>

<li><p>baz</p></li>
</ul>
2 changes: 0 additions & 2 deletions test/cases/unordered-list-asterisk.html
@@ -1,7 +1,5 @@
<ul>
<li>Red</li>

<li>Green</li>

<li>Blue</li>
</ul>
2 changes: 0 additions & 2 deletions test/cases/unordered-list-minus.html
@@ -1,7 +1,5 @@
<ul>
<li>Red</li>

<li>Green</li>

<li>Blue</li>
</ul>
2 changes: 0 additions & 2 deletions test/cases/unordered-list-plus.html
@@ -1,7 +1,5 @@
<ul>
<li>Red</li>

<li>Green</li>

<li>Blue</li>
</ul>
3 changes: 0 additions & 3 deletions test/features/#164.4.tasklists.html
@@ -1,11 +1,8 @@
<h1 id="mythings">my things</h1>
<ul>
<li>foo</li>

<li class="task-list-item" style="list-style-type: none;"><input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"> bar</li>

<li class="task-list-item" style="list-style-type: none;"><input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"> baz</li>

<li class="task-list-item" style="list-style-type: none;"><input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;" checked> bazinga</li>
</ul>
<p>otherthings</p>
Expand Up @@ -2,6 +2,5 @@ <h2 id="markdowndoc">markdown doc</h2>
<p>you can use markdown for card documentation</p>
<ul>
<li>foo</li>

<li>bar</li>
</ul>
2 changes: 0 additions & 2 deletions test/ghost/underscore.html
Expand Up @@ -23,15 +23,13 @@ <h2 id="foo_bar_bazfoo_bar_baz_bar_foo_foo_barbaz_bar_baz_foo">foo_bar_baz foo_b
<h3 id="foo_bar_bazfoo_bar_baz_bar_foo_foo_barbaz_bar_baz_foo-1">foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</h3>
<ol>
<li>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</li>

<li>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</li>
</ol>
<blockquote>
<p>blockquote foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</p>
</blockquote>
<ul>
<li>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</li>

<li>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</li>
</ul>
<hr />
Expand Down
@@ -1,15 +1,12 @@
<ul>
<li>Item 1</li>

<li>Item 2</li>
</ul>
<ol>
<li>Item 1</li>

<li>Item 2</li>
</ol>
<ul>
<li>Item 1</li>

<li>Item 2</li>
</ul>
@@ -1,13 +1,12 @@
<ol>
<li><p>Hi, I am a thing</p>
<pre><code class="sh language-sh">$ git clone thing.git
<li><p>Hi, I am a thing</p>
<pre><code class="sh language-sh">$ git clone thing.git

dfgdfg
</code></pre></li>

<li><p>I am another thing!</p>
<pre><code class="sh language-sh">$ git clone other-thing.git
</code></pre></li>
<li><p>I am another thing!</p>
<pre><code class="sh language-sh">$ git clone other-thing.git

foobar
</code></pre></li>
</code></pre></li>
</ol>
4 changes: 0 additions & 4 deletions test/issues/#196.entity-in-code-block-in-nested-list.html
@@ -1,21 +1,17 @@
<p>Test pre in a list</p>
<ul>
<li>&amp; &lt;</li>

<li><code>&amp; &lt;</code>

<ul>
<li>&amp; &lt;</li>

<li><code>&amp; &lt;</code>

<ul>
<li>&amp; &lt;</li>

<li><code>&amp; &lt;</code>

<ul>
<li>&amp; &lt;</li>

<li><code>&amp; &lt;</code></li></ul></li></ul></li></ul></li>
</ul>
@@ -1,14 +1,13 @@
<ul>
<li><p>list item 1</p>
<li><p>list item 1</p>
<pre><code>&lt;parent&gt;
&lt;child&gt;child1&lt;/child&gt;
&lt;!-- This is a comment --&gt;
&lt;child&gt;child2&lt;/child&gt;
&lt;child&gt;some text &lt;!-- a comment --&gt;&lt;/child&gt;
&lt;/parent&gt;
</code></pre></li>

<li><p>list item 2</p></li>
<li><p>list item 2</p></li>
</ul>
<pre><code>&lt;parent&gt;
&lt;child&gt;child1&lt;/child&gt;
Expand Down
1 change: 0 additions & 1 deletion test/karlcow/list-multiparagraphs-tab.html
Expand Up @@ -5,6 +5,5 @@
<p>Vestibulum enim wisi, viverra nec, fringilla in, laoreet
vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
sit amet velit.</p></li>

<li><p>Suspendisse id sem consectetuer libero luctus adipiscing.</p></li>
</ul>
1 change: 0 additions & 1 deletion test/karlcow/list-multiparagraphs.html
Expand Up @@ -5,6 +5,5 @@
<p>Vestibulum enim wisi, viverra nec, fringilla in, laoreet
vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
sit amet velit.</p></li>

<li><p>Suspendisse id sem consectetuer libero luctus adipiscing.</p></li>
</ul>
1 change: 0 additions & 1 deletion test/karlcow/ordered-list-inner-par-list.html
Expand Up @@ -2,6 +2,5 @@
<li><p>1</p>
<ul>
<li>inner par list</li></ul></li>

<li><p>2</p></li>
</ol>
2 changes: 0 additions & 2 deletions test/karlcow/ordered-list-items-random-number.html
@@ -1,7 +1,5 @@
<ol>
<li>list item 1</li>

<li>list item 2</li>

<li>list item 3</li>
</ol>
2 changes: 0 additions & 2 deletions test/karlcow/ordered-list-items.html
@@ -1,7 +1,5 @@
<ol>
<li>list item 1</li>

<li>list item 2</li>

<li>list item 3</li>
</ol>
2 changes: 0 additions & 2 deletions test/karlcow/unordered-list-items-asterisk.html
@@ -1,7 +1,5 @@
<ul>
<li>list item 1</li>

<li>list item 2</li>

<li>list item 3</li>
</ul>
2 changes: 0 additions & 2 deletions test/karlcow/unordered-list-items-dashsign.html
@@ -1,7 +1,5 @@
<ul>
<li>list item 1</li>

<li>list item 2</li>

<li>list item 3</li>
</ul>
2 changes: 0 additions & 2 deletions test/karlcow/unordered-list-items-leading-1space.html
@@ -1,7 +1,5 @@
<ul>
<li>list item 1</li>

<li>list item 2</li>

<li>list item 3</li>
</ul>
2 changes: 0 additions & 2 deletions test/karlcow/unordered-list-items-leading-2spaces.html
@@ -1,7 +1,5 @@
<ul>
<li>list item 1</li>

<li>list item 2</li>

<li>list item 3</li>
</ul>
2 changes: 0 additions & 2 deletions test/karlcow/unordered-list-items-leading-3spaces.html
@@ -1,7 +1,5 @@
<ul>
<li>list item 1</li>

<li>list item 2</li>

<li>list item 3</li>
</ul>
2 changes: 0 additions & 2 deletions test/karlcow/unordered-list-items-plussign.html
@@ -1,7 +1,5 @@
<ul>
<li>list item 1</li>

<li>list item 2</li>

<li>list item 3</li>
</ul>

0 comments on commit 2b813cd

Please sign in to comment.