fix(lists linebreaks): fix lists linebreaks in html output

Closes #291
This commit is contained in:
Estevao Soares dos Santos 2016-09-29 01:12:27 +01:00
parent f97e072bc4
commit 2b813cd3fb
39 changed files with 12 additions and 73 deletions

BIN
dist/showdown.js vendored

Binary file not shown.

BIN
dist/showdown.js.map vendored

Binary file not shown.

BIN
dist/showdown.min.js vendored

Binary file not shown.

Binary file not shown.

View File

@ -77,7 +77,7 @@ showdown.subParser('lists', function (text, options, globals) {
item = showdown.subParser('spanGamut')(item, options, globals); item = showdown.subParser('spanGamut')(item, options, globals);
} }
} }
item = '\n<li' + bulletStyle + '>' + item + '</li>\n'; item = '<li' + bulletStyle + '>' + item + '</li>\n';
return item; return item;
}); });
@ -112,7 +112,7 @@ showdown.subParser('lists', function (text, options, globals) {
var pos = txt.search(counterRxg); var pos = txt.search(counterRxg);
if (pos !== -1) { if (pos !== -1) {
// slice // 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 // invert counterType and listType
listType = (listType === 'ul') ? 'ol' : 'ul'; listType = (listType === 'ul') ? 'ol' : 'ul';
@ -121,14 +121,14 @@ showdown.subParser('lists', function (text, options, globals) {
//recurse //recurse
parseCL(txt.slice(pos)); parseCL(txt.slice(pos));
} else { } else {
result += '\n<' + listType + '>' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n'; result += '\n<' + listType + '>\n' + processListItems(txt, !!trimTrailing) + '</' + listType + '>\n';
} }
})(list); })(list);
for (var i = 0; i < subLists.length; ++i) { for (var i = 0; i < subLists.length; ++i) {
} }
} else { } else {
result = '\n<' + listType + '>' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n'; result = '\n<' + listType + '>\n' + processListItems(list, !!trimTrailing) + '</' + listType + '>\n';
} }
return result; return result;

View File

@ -2,7 +2,6 @@
<h2 id="thisisaheader">This is a header.</h2> <h2 id="thisisaheader">This is a header.</h2>
<ol> <ol>
<li>This is the first list item.</li> <li>This is the first list item.</li>
<li>This is the second list item.</li> <li>This is the second list item.</li>
</ol> </ol>
<p>Here's some example code:</p> <p>Here's some example code:</p>

View File

@ -1,5 +1,4 @@
<ul> <ul>
<li><p>Bird</p></li> <li><p>Bird</p></li>
<li><p>Magic</p></li> <li><p>Magic</p></li>
</ul> </ul>

View File

@ -1,7 +1,6 @@
<h1 id="sometitle">some title</h1> <h1 id="sometitle">some title</h1>
<ol> <ol>
<li>list item 1</li> <li>list item 1</li>
<li>list item 2</li> <li>list item 2</li>
</ol> </ol>
<blockquote> <blockquote>
@ -9,6 +8,5 @@
</blockquote> </blockquote>
<ul> <ul>
<li>another list item 1</li> <li>another list item 1</li>
<li>another list item 2</li> <li>another list item 2</li>
</ul> </ul>

View File

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

View File

@ -1,6 +1,5 @@
<ol> <ol>
<li><p>This is a major bullet point.</p> <li><p>This is a major bullet point.</p>
<p>That contains multiple paragraphs.</p></li> <p>That contains multiple paragraphs.</p></li>
<li><p>And another line</p></li> <li><p>And another line</p></li>
</ol> </ol>

View File

@ -1,6 +1,5 @@
<ul> <ul>
<li>This line spans <li>This line spans
more than one line and is lazy</li> more than one line and is lazy</li>
<li>Similar to this line</li> <li>Similar to this line</li>
</ul> </ul>

View File

@ -1,7 +1,5 @@
<ol> <ol>
<li>Red</li> <li>Red</li>
<li>Green</li> <li>Green</li>
<li>Blue</li> <li>Blue</li>
</ol> </ol>

View File

@ -1,7 +1,5 @@
<ol> <ol>
<li>Red</li> <li>Red</li>
<li>Green</li> <li>Green</li>
<li>Blue</li> <li>Blue</li>
</ol> </ol>

View File

@ -1,7 +1,5 @@
<ol> <ol>
<li>Red</li> <li>Red</li>
<li>Green</li> <li>Green</li>
<li>Blue</li> <li>Blue</li>
</ol> </ol>

View File

@ -2,14 +2,10 @@
<li><p>foo</p> <li><p>foo</p>
<ul> <ul>
<li><p>bazinga</p></li> <li><p>bazinga</p></li>
<li><p>yeah</p></li></ul></li> <li><p>yeah</p></li></ul></li>
<li><p>bar</p> <li><p>bar</p>
<ol> <ol>
<li><p>damn</p></li> <li><p>damn</p></li>
<li><p>so many paragraphs</p></li></ol></li> <li><p>so many paragraphs</p></li></ol></li>
<li><p>baz</p></li> <li><p>baz</p></li>
</ul> </ul>

View File

@ -1,7 +1,5 @@
<ul> <ul>
<li>Red</li> <li>Red</li>
<li>Green</li> <li>Green</li>
<li>Blue</li> <li>Blue</li>
</ul> </ul>

View File

@ -1,7 +1,5 @@
<ul> <ul>
<li>Red</li> <li>Red</li>
<li>Green</li> <li>Green</li>
<li>Blue</li> <li>Blue</li>
</ul> </ul>

View File

@ -1,7 +1,5 @@
<ul> <ul>
<li>Red</li> <li>Red</li>
<li>Green</li> <li>Green</li>
<li>Blue</li> <li>Blue</li>
</ul> </ul>

View File

@ -1,11 +1,8 @@
<h1 id="mythings">my things</h1> <h1 id="mythings">my things</h1>
<ul> <ul>
<li>foo</li> <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;"> 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;"> 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> <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> </ul>
<p>otherthings</p> <p>otherthings</p>

View File

@ -2,6 +2,5 @@
<p>you can use markdown for card documentation</p> <p>you can use markdown for card documentation</p>
<ul> <ul>
<li>foo</li> <li>foo</li>
<li>bar</li> <li>bar</li>
</ul> </ul>

View File

@ -23,7 +23,6 @@
<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> <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> <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>
<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> </ol>
<blockquote> <blockquote>
@ -31,7 +30,6 @@
</blockquote> </blockquote>
<ul> <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>
<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> </ul>
<hr /> <hr />

View File

@ -1,15 +1,12 @@
<ul> <ul>
<li>Item 1</li> <li>Item 1</li>
<li>Item 2</li> <li>Item 2</li>
</ul> </ul>
<ol> <ol>
<li>Item 1</li> <li>Item 1</li>
<li>Item 2</li> <li>Item 2</li>
</ol> </ol>
<ul> <ul>
<li>Item 1</li> <li>Item 1</li>
<li>Item 2</li> <li>Item 2</li>
</ul> </ul>

View File

@ -1,13 +1,12 @@
<ol> <ol>
<li><p>Hi, I am a thing</p> <li><p>Hi, I am a thing</p>
<pre><code class="sh language-sh">$ git clone thing.git <pre><code class="sh language-sh">$ git clone thing.git
dfgdfg dfgdfg
</code></pre></li> </code></pre></li>
<li><p>I am another thing!</p>
<li><p>I am another thing!</p> <pre><code class="sh language-sh">$ git clone other-thing.git
<pre><code class="sh language-sh">$ git clone other-thing.git
foobar foobar
</code></pre></li> </code></pre></li>
</ol> </ol>

View File

@ -1,21 +1,17 @@
<p>Test pre in a list</p> <p>Test pre in a list</p>
<ul> <ul>
<li>&amp; &lt;</li> <li>&amp; &lt;</li>
<li><code>&amp; &lt;</code> <li><code>&amp; &lt;</code>
<ul> <ul>
<li>&amp; &lt;</li> <li>&amp; &lt;</li>
<li><code>&amp; &lt;</code> <li><code>&amp; &lt;</code>
<ul> <ul>
<li>&amp; &lt;</li> <li>&amp; &lt;</li>
<li><code>&amp; &lt;</code> <li><code>&amp; &lt;</code>
<ul> <ul>
<li>&amp; &lt;</li> <li>&amp; &lt;</li>
<li><code>&amp; &lt;</code></li></ul></li></ul></li></ul></li> <li><code>&amp; &lt;</code></li></ul></li></ul></li></ul></li>
</ul> </ul>

View File

@ -1,5 +1,5 @@
<ul> <ul>
<li><p>list item 1</p> <li><p>list item 1</p>
<pre><code>&lt;parent&gt; <pre><code>&lt;parent&gt;
&lt;child&gt;child1&lt;/child&gt; &lt;child&gt;child1&lt;/child&gt;
&lt;!-- This is a comment --&gt; &lt;!-- This is a comment --&gt;
@ -7,8 +7,7 @@
&lt;child&gt;some text &lt;!-- a comment --&gt;&lt;/child&gt; &lt;child&gt;some text &lt;!-- a comment --&gt;&lt;/child&gt;
&lt;/parent&gt; &lt;/parent&gt;
</code></pre></li> </code></pre></li>
<li><p>list item 2</p></li>
<li><p>list item 2</p></li>
</ul> </ul>
<pre><code>&lt;parent&gt; <pre><code>&lt;parent&gt;
&lt;child&gt;child1&lt;/child&gt; &lt;child&gt;child1&lt;/child&gt;

View File

@ -5,6 +5,5 @@ mi posuere lectus.</p>
<p>Vestibulum enim wisi, viverra nec, fringilla in, laoreet <p>Vestibulum enim wisi, viverra nec, fringilla in, laoreet
vitae, risus. Donec sit amet nisl. Aliquam semper ipsum vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
sit amet velit.</p></li> sit amet velit.</p></li>
<li><p>Suspendisse id sem consectetuer libero luctus adipiscing.</p></li> <li><p>Suspendisse id sem consectetuer libero luctus adipiscing.</p></li>
</ul> </ul>

View File

@ -5,6 +5,5 @@ mi posuere lectus.</p>
<p>Vestibulum enim wisi, viverra nec, fringilla in, laoreet <p>Vestibulum enim wisi, viverra nec, fringilla in, laoreet
vitae, risus. Donec sit amet nisl. Aliquam semper ipsum vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
sit amet velit.</p></li> sit amet velit.</p></li>
<li><p>Suspendisse id sem consectetuer libero luctus adipiscing.</p></li> <li><p>Suspendisse id sem consectetuer libero luctus adipiscing.</p></li>
</ul> </ul>

View File

@ -2,6 +2,5 @@
<li><p>1</p> <li><p>1</p>
<ul> <ul>
<li>inner par list</li></ul></li> <li>inner par list</li></ul></li>
<li><p>2</p></li> <li><p>2</p></li>
</ol> </ol>

View File

@ -1,7 +1,5 @@
<ol> <ol>
<li>list item 1</li> <li>list item 1</li>
<li>list item 2</li> <li>list item 2</li>
<li>list item 3</li> <li>list item 3</li>
</ol> </ol>

View File

@ -1,7 +1,5 @@
<ol> <ol>
<li>list item 1</li> <li>list item 1</li>
<li>list item 2</li> <li>list item 2</li>
<li>list item 3</li> <li>list item 3</li>
</ol> </ol>

View File

@ -1,7 +1,5 @@
<ul> <ul>
<li>list item 1</li> <li>list item 1</li>
<li>list item 2</li> <li>list item 2</li>
<li>list item 3</li> <li>list item 3</li>
</ul> </ul>

View File

@ -1,7 +1,5 @@
<ul> <ul>
<li>list item 1</li> <li>list item 1</li>
<li>list item 2</li> <li>list item 2</li>
<li>list item 3</li> <li>list item 3</li>
</ul> </ul>

View File

@ -1,7 +1,5 @@
<ul> <ul>
<li>list item 1</li> <li>list item 1</li>
<li>list item 2</li> <li>list item 2</li>
<li>list item 3</li> <li>list item 3</li>
</ul> </ul>

View File

@ -1,7 +1,5 @@
<ul> <ul>
<li>list item 1</li> <li>list item 1</li>
<li>list item 2</li> <li>list item 2</li>
<li>list item 3</li> <li>list item 3</li>
</ul> </ul>

View File

@ -1,7 +1,5 @@
<ul> <ul>
<li>list item 1</li> <li>list item 1</li>
<li>list item 2</li> <li>list item 2</li>
<li>list item 3</li> <li>list item 3</li>
</ul> </ul>

View File

@ -1,7 +1,5 @@
<ul> <ul>
<li>list item 1</li> <li>list item 1</li>
<li>list item 2</li> <li>list item 2</li>
<li>list item 3</li> <li>list item 3</li>
</ul> </ul>

View File

@ -1,5 +1,4 @@
<ul> <ul>
<li><p>list item in paragraph</p></li> <li><p>list item in paragraph</p></li>
<li><p>another list item in paragraph</p></li> <li><p>another list item in paragraph</p></li>
</ul> </ul>

View File

@ -1,5 +1,4 @@
<ul> <ul>
<li>This a very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long paragraph in a list.</li> <li>This a very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long paragraph in a list.</li>
<li>and yet another long long long long long long long long long long long long long long long long long long long long long long line.</li> <li>and yet another long long long long long long long long long long long long long long long long long long long long long long line.</li>
</ul> </ul>

View File

@ -2,7 +2,6 @@
<li>This is a list item <li>This is a list item
with the content on with the content on
multiline and indented.</li> multiline and indented.</li>
<li>And this another list item <li>And this another list item
with the same principle.</li> with the same principle.</li>
</ul> </ul>