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

Ordered and unordered lists are combined unless separated by three newlines #170

Open
noahmoss opened this issue Aug 13, 2021 · 3 comments
Labels

Comments

@noahmoss
Copy link

Hello!

I noticed this behavior, which is not what I would have expected:

> (markdown.core/md-to-html-string "1. one\n2. two\n\n* three\n* four")
"<ol><li>one</li><li>two</li><li>three</li><li>four</li></ol>"

> (markdown.core/md-to-html-string "1. one\n2. two\n\n\n* three\n* four")
"<ol><li>one</li><li>two</li></ol><ul><li>three</li><li>four</li></ul>"

Most markdown parsers, as far as I can tell, will keep the ordered and unordered lists separate if there's even just a single newline between them.

Would you consider this a bug?

@yogthos yogthos added the bug label Aug 14, 2021
@yogthos
Copy link
Owner

yogthos commented Aug 14, 2021

That does look like an unintended behavior that slipped by, and I'm open to updating the parser to be inline with other parsers. I might not have the time to look at this in the near future, but I could help guide a PR if you'd be interested at taking a look. :)

@noahmoss
Copy link
Author

@yogthos I'd be happy to contribute! If you have any pointers to where changes would have to be made, that would be great.

@yogthos
Copy link
Owner

yogthos commented Aug 15, 2021

Fantastic, and this is probably a good place to start. The parser analyzes text line by line, and the function takes two arguments which are text and state. The text is the current line, and the state is a map specifying what the state of the parser currently is. So, the trick would be to identify when the next line shouldn't be treated as part of the current list.

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

No branches or pull requests

2 participants