Fix for compound nested list issues, passes regression tests.
License statement:
I am the original author of this fix and make it available under the same license as pegdown.
Fixes issues: #57, #123
This PR has the fixed list parsing that includes tight and loose sub-list handling that the previous fix did not address. It also does not mess up definitions because these relied on the old parser rule for list parsing. Definition list rule is now a copy of the old list parsing rule so that regression tests pass.
Change to pegdown.spec: AstText.ast changed to reflect that the new parsing of list items does not include the trailing blank lines in the item. This makes the new behavior leave out a blank line of 2 spaces at the end of the list causing a discrepancy of 3 characters for the BulletListNode. Expectation file modified to reflect new reality.
I'll create another PR in a day or two with new tests to validate compound nested lists.
sbt test result summary:
[info] Passed: Total 19, Failed 0, Errors 0, Passed 19
[success] Total time: 2 s, completed 14-Aug-2015 12:04:09 AM
Output results of parsing compound nested list. Minor differences with GitHub which makes list items above and below a blank line loose. Pegdown only makes the item following a blank line loose. It's a toss up but I think pegdown's results are more intuitive:
For:
2. XYZ 1
XYZ 1's paragraph
1. A 1
2. A 2
3. A 3
GitHub Produces:
XYZ 1
XYZ 1’s paragraph
A 1
A 2
A 3
A 3’s paragraph
while pegdown produces what you would expect by looking at the markdown source:
XYZ 1
XYZ 1’s paragraph
A 1
A 2
A 3
A 3’s paragraph
Full output: raw markdown, markdown - to let GitHub convert to HTML, HTML - converted by pegdown to render by GitHub for comparison, raw HTML for the curious.
-- raw markdown -------------------------------------------
1. B 1
1. A 1
2. A 2
<!-- end list -->
1. B 1
1. A 1
2. A 2
<!-- end list -->
1. B 1
1. A 1
2. A 2
<!-- end list -->
2. XYZ 1
XYZ 1's paragraph
1. A 1
2. A 2
3. A 3
A 3's paragraph
- XYZ
1. abc
1. abc
1. abc
- XYZ
- abc
-- markdown -----------------------------------------------
1. B 1
1. A 1
2. A 2
<!-- end list -->
1. B 1
1. A 1
2. A 2
<!-- end list -->
1. B 1
1. A 1
2. A 2
<!-- end list -->
1. XYZ 1
XYZ 1's paragraph
1. A 1
2. A 2
3. A 3
A 3's paragraph
- XYZ
1. abc
2. abc
3. abc
- XYZ
- abc
Fix for compound nested list issues, passes regression tests.
License statement:
I am the original author of this fix and make it available under the same license as pegdown.
Fixes issues: #57, #123
This PR has the fixed list parsing that includes tight and loose sub-list handling that the previous fix did not address. It also does not mess up definitions because these relied on the old parser rule for list parsing. Definition list rule is now a copy of the old list parsing rule so that regression tests pass.
Change to pegdown.spec: AstText.ast changed to reflect that the new parsing of list items does not include the trailing blank lines in the item. This makes the new behavior leave out a blank line of 2 spaces at the end of the list causing a discrepancy of 3 characters for the BulletListNode. Expectation file modified to reflect new reality.
I'll create another PR in a day or two with new tests to validate compound nested lists.
sbt test
result summary:Output results of parsing compound nested list. Minor differences with GitHub which makes list items above and below a blank line loose. Pegdown only makes the item following a blank line loose. It's a toss up but I think pegdown's results are more intuitive:
For:
GitHub Produces:
XYZ 1
XYZ 1’s paragraph
A 2
A 3
A 3’s paragraph
while pegdown produces what you would expect by looking at the markdown source:
XYZ 1
XYZ 1’s paragraph
A 3
A 3’s paragraph
Full output: raw markdown, markdown - to let GitHub convert to HTML, HTML - converted by pegdown to render by GitHub for comparison, raw HTML for the curious.
-- raw markdown -------------------------------------------
XYZ 2
List 1 Item 1
sub list item 1 sub list item 1 continuation line
sub list item 1 paragraph
sub list item 2
List 1 Item 1 paragraph
List 1 Item 1 paragraph or main code block
List 1 Item 1
sub list item 1 sub list item 1 continuation line
sub list item 1 paragraph
List 1 Item 1 paragraph
List 1 Item 1 paragraph or main code block
-- HTML ---------------------------------------------------
B 1
A 1
A 2
A 1
A 2
B 1
XYZ 1
XYZ 1’s paragraph
A 3
A 3’s paragraph
abc
abc
Lorem ipsum…
XYZ 2
List 1 Item 1
sub list item 1
sub list item 1 continuation line
sub list item 1 paragraph
sub list item 2
List 1 Item 1 paragraph
List 1 Item 1 paragraph or main code block
-- raw HTML -----------------------------------------------