sirthias / pegdown

A pure-Java Markdown processor based on a parboiled PEG parser supporting a number of extensions
http://pegdown.org
Apache License 2.0
1.29k stars 217 forks source link

nested list rendering is incorrect #123

Closed sslepian closed 9 years ago

sslepian commented 10 years ago

Pegdown appears to render nested ordered lists incorrectly, which breaks the list numbering for the child lists.

For the following Markdown

1. a

    1. a

    2. b

2. b

    1. a

    2. b

Here's the HTML output by John Gruber's Markdown test site:

http://jsfiddle.net/u7GJt/

And here's the HTML output of Pegdown:

http://jsfiddle.net/qTDs6/

Pegdown's output is breaking the inner list into two separate

    tags, which breaks list numbering.

sirthias commented 10 years ago

Hmm... yes. This look like a bug. THanks for reporting!

TiS commented 9 years ago

I have similar issue

I have following markdown:

2. XYZ
    1. A

        - XYZ
        - XYZ
        - XYZ

        Lorem ipsum...

    2. B
        - XYZ
        - XYZ
        - XYZ

As you see, GitHUB (and other MarkDown editors I checked) render this as follows:

  1. XYZ

    1. A

      • XYZ
      • XYZ
      • XYZ

      Lorem ipsum...

    2. B
      • XYZ
      • XYZ
      • XYZ

Unfortunately, this library treats first sub-sub list (and the Lorem Ipsum) as code block. What's more, it restarts list numbering for sub-list (A,B).

vsch commented 9 years ago

The list parser has errors in the parsing rules. These showed up for loose sub-items because not all relevant text was collected for recursive parsing of sub-item elements. Pull request posted.