markdown-js
markdown-js copied to clipboard
How to create a numbered list?
- test
- test
- test
This creates a bullet list for me. How come this doesn't created a number 1,2,3 list?
I was just looking around for the same answer and the stumbled across the cause. I had the following:
* Bullet
* List
1. Numeric
2. List
This was being joined together as a single list, and so inheriting the bullet types from the first part. Separating it with another element (some text) split it into two lists and gave it the expected behaviour:
* Bullet
* List
Some text here
1. Numeric
2. List
There has to be another element between the lists, otherwise they join. You can have as many line breaks as you like between the lists, all that happens is that the 1. Numeric item is wrapped in a <p> tag.
Suggestions:
- Could the code detect a change in the type of list?
- Could there be a maximum of one empty line between list items?
This is definitely a bug. The list parsing code is the messiest part of this code - it gets nastily complex trying to deal with nested lists and paragraphs in lists etc.
@ewels thanks for the details test case! We should be able to do it as per your first suggestion.
Turns out we are 'bug compatible' with the original markdown implementation here: http://johnmacfarlane.net/babelmark2/?text=+Bullet%0A+List%0A%0A1.+Numeric%0A2.+List
I think this is probably a case where this behaviour is so unexpected that we should do it properly.