Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested lists are broken #245

Open
weavejester opened this issue Sep 14, 2016 · 4 comments
Open

Nested lists are broken #245

weavejester opened this issue Sep 14, 2016 · 4 comments

Comments

@weavejester
Copy link

weavejester commented Sep 14, 2016

Pegdown 1.6.0 has problems rendering nested lists. This issue also occurs in 1.5.0, 1.4.0 and 1.3.0, so it appears to be a long-standing issue.

* foo
  * bar
<ul>
  <li>foo</li>
  <li>bar</li>
</ul>

Similarly:

* foo

  bar
<ul>
  <li>foo</li>
</ul>
<p>bar</p>

However, if I double the indentation, it works:

* foo
    * bar
<ul>
  <li>foo
    <ul>
      <li>bar</li>
    </ul>
  </li>
</ul>

Looking at the code, it seems like Pegdown treats indentation as either a tab or four spaces, but for lists any whitespace should be treated as indentation.

@weavejester weavejester changed the title Nested lists are broken Nested lists are broken in 1.6.0 Sep 14, 2016
@weavejester weavejester changed the title Nested lists are broken in 1.6.0 Nested lists are broken Sep 14, 2016
@vsch
Copy link
Contributor

vsch commented Dec 12, 2016

@weavejester, pegdown uses fixed indent based list parsing, like MultiMarkdown and pandoc. Your list would be parsed as a list in kramdown, markdown.pl and CommonMark. Differences in list parsing is the greatest deviation between implementations.

@weavejester
Copy link
Author

Ah, I see. Maybe the title shouldn't be "Markdown lists are broken", but "Markdown lists don't work like they do on Github" :)

@vsch
Copy link
Contributor

vsch commented Dec 12, 2016

@weavejester, if you need GitHub like processing then you need to clarify GitHub comments or GitHub docs. They switched comment processing to CommonMark. Docs are still kramdown.

I rewrote commonmark-java to replace pegdown in my Markdown Navigator plugin for IntelliJ IDEs: https://github.com/vsch/idea-multimarkdown. The parser project is https://github.com/vsch/flexmark-java has very detailed source based AST with source offset for every part of the element. I need that for syntax highlighting and other plugin source reliant features.

It is CommonMark 0.27 (GitHub Comments) compliant but has parser configuration options to emulate list indentation rules used by: markdown.pl, MultiMarkdown (like pegdown 4 space indents) and kramdown (GitHub Docs). The only extensions that pegdown has that I did not yet implement are: typographic quotes, smarts and definition lists. The rest of the extensions are available, with some extra ones that pegdown does not have.

As an added bonus and what motivated me to switch the parsing is 30-50x faster than pegdown on average documents and several thousand times faster on pegdown's pathological input like [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[.

The AST offsets are bug free and regular. It is also fully modifiable unlike pegdown's with next, prev and parent links.

@craneyuan
Copy link

craneyuan commented May 16, 2017

@weavejester thank you very much! 👍
I also encountered this problem, just wondering how to deal with, and i am very lucky to find this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants