Skip to content

Commit a2259c0

Browse files
committed
fix(lists): fix multi paragraph lists with sublists
Paragraphed lists with sublists were being parsed incorrectly due to workaround realted with simpleLineBreaks. This commit fixes this. Closes #397
1 parent 5a5aff6 commit a2259c0

8 files changed

Lines changed: 41 additions & 14 deletions

File tree

dist/showdown.js

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/showdown.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/subParsers/lists.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,14 @@ showdown.subParser('lists', function (text, options, globals) {
9393
item = showdown.subParser('lists')(item, options, globals);
9494
item = item.replace(/\n$/, ''); // chomp(item)
9595
item = showdown.subParser('hashHTMLBlocks')(item, options, globals);
96+
9697
// Colapse double linebreaks
9798
item = item.replace(/\n\n+/g, '\n\n');
98-
// replace double linebreaks with a placeholder
99-
item = item.replace(/\n\n/g, '¨B');
10099
if (isParagraphed) {
101100
item = showdown.subParser('paragraphs')(item, options, globals);
102101
} else {
103102
item = showdown.subParser('spanGamut')(item, options, globals);
104103
}
105-
item = item.replace(/¨B/g, '\n\n');
106104
}
107105

108106
// now we need to remove the marker (¨A)

src/subParsers/spanGamut.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ showdown.subParser('spanGamut', function (text, options, globals) {
3232
// Do hard breaks
3333
if (options.simpleLineBreaks) {
3434
// GFM style hard breaks
35-
text = text.replace(/\n/g, '<br />\n');
35+
// only add line breaks if the text does not contain a block (special case for lists)
36+
if (!/\n\n¨K/.test(text)) {
37+
text = text.replace(/\n+/g, '<br />\n');
38+
}
3639
} else {
3740
// Vanilla hard breaks
3841
text = text.replace(/ +\n/g, '<br />\n');
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<ul>
2+
<li><p><strong>Customer</strong> – Opens the Customer List. Refer to the document “Customer Management”.</p>
3+
<ul>
4+
<li>Customer List</li>
5+
<li>New Customer</li>
6+
<li>Customer Prices</li>
7+
<li>Appointments</li></ul></li>
8+
<li><p><strong>Designer</strong> - Opens the Designer List. Refer to the document “Designer Commissions”.</p>
9+
<ul>
10+
<li>Designer List</li>
11+
<li>New Designer</li>
12+
<li>Designer Payment List</li>
13+
<li>New Designer Payment</li></ul></li>
14+
</ul>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- **Customer** – Opens the Customer List. Refer to the document “Customer Management”.
2+
- Customer List
3+
- New Customer
4+
- Customer Prices
5+
- Appointments
6+
7+
- **Designer** - Opens the Designer List. Refer to the document “Designer Commissions”.
8+
- Designer List
9+
- New Designer
10+
- Designer Payment List
11+
- New Designer Payment

0 commit comments

Comments
 (0)