-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lists): enforce 4 space indentation in sublists
Acording to the spec, multi paragraph (or block) list item requires subblocks to be indented 4 spaces (or 1 tab). Although, this is mentioned in the documentation, Showdown didn't enforce this rule in sublists because other implementations, such as GFM also didn't. However, in some edge cases, this led to inconsistent behavior, as shown in issue #299. This commit makes 4 space indentation in sublists mandatory. BREAKING CHANGE: syntax for sublists is more restrictive. Before, sublists SHOULD be indented by 4 spaces, but indenting 2 spaces would work. Now, sublists MUST be indented 4 spaces or they won't work. With this input: ```md * one * two * three ``` Before (ouput): ```html <ul> <li>one <ul> <li>two <ul><li>three</li></ul> <li> </ul> </li> <ul> ``` After (output): ```html <ul> <li>one</li> <li>two <ul><li>three</li></ul> </li> </ul> ``` To migrate either fix source md files or activate the option `disableForced4SpacesIndentedSublists` (coming in v1.5.0): ```md showdown.setOption('disableForced4SpacesIndentedSublists', true); ```
- Loading branch information
Showing
13 changed files
with
236 additions
and
58 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
- foo | ||
|
||
- bazinga | ||
- bazinga | ||
|
||
- yeah | ||
- yeah | ||
|
||
- bar | ||
|
||
1. damn | ||
1. damn | ||
|
||
2. so many paragraphs | ||
2. so many paragraphs | ||
|
||
- baz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
test/issues/#299.nested-ordered-unordered-list-inconsistent-behavior-2.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<ul> | ||
<li>one</li> | ||
</ul> | ||
<ol> | ||
<li>two</li> | ||
</ol> | ||
<p>foo</p> | ||
<ul> | ||
<li>one</li> | ||
</ul> | ||
<ol> | ||
<li>two</li> | ||
</ol> | ||
<p>foo</p> | ||
<ul> | ||
<li>one</li> | ||
</ul> | ||
<ol> | ||
<li>two</li> | ||
</ol> | ||
<p>foo</p> | ||
<ul> | ||
<li>one | ||
|
||
<ol> | ||
<li>two</li></ol></li> | ||
</ul> | ||
<p>foo</p> | ||
<ul> | ||
<li>one</li> | ||
<li>two</li> | ||
</ul> | ||
<p>foo</p> | ||
<ul> | ||
<li>one</li> | ||
<li>two</li> | ||
</ul> | ||
<p>foo</p> | ||
<ul> | ||
<li>one</li> | ||
<li>two</li> | ||
</ul> | ||
<p>foo</p> | ||
<ul> | ||
<li>one</li> | ||
<li>two</li> | ||
</ul> | ||
<p>foo</p> | ||
<ul> | ||
<li>one | ||
|
||
<ul> | ||
<li>two</li></ul></li> | ||
</ul> |
42 changes: 42 additions & 0 deletions
42
test/issues/#299.nested-ordered-unordered-list-inconsistent-behavior-2.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
* one | ||
1. two | ||
|
||
foo | ||
|
||
* one | ||
1. two | ||
|
||
foo | ||
|
||
* one | ||
1. two | ||
|
||
foo | ||
|
||
* one | ||
1. two | ||
|
||
foo | ||
|
||
* one | ||
* two | ||
|
||
foo | ||
|
||
* one | ||
* two | ||
|
||
foo | ||
|
||
* one | ||
* two | ||
|
||
foo | ||
|
||
* one | ||
* two | ||
|
||
foo | ||
|
||
* one | ||
* two |
15 changes: 15 additions & 0 deletions
15
test/issues/#299.nested-ordered-unordered-list-inconsistent-behavior-3.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<ul> | ||
<li>one long paragraph of | ||
text</li> | ||
</ul> | ||
<ol> | ||
<li>two</li> | ||
</ol> | ||
<p>foo</p> | ||
<ul> | ||
<li>one long paragraph of | ||
text</li> | ||
</ul> | ||
<ol> | ||
<li>two</li> | ||
</ol> |
9 changes: 9 additions & 0 deletions
9
test/issues/#299.nested-ordered-unordered-list-inconsistent-behavior-3.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
* one long paragraph of | ||
text | ||
1. two | ||
|
||
foo | ||
|
||
* one long paragraph of | ||
text | ||
1. two |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.