Incorrect conversion of numbered list
See original GitHub issueTried converting the following file: https://raw.githubusercontent.com/laboon/CS1530_Fall2017/master/reading-quizzes/quiz4.md
using the command line tool. The file has a numbered list
1. item one
2. item two
3. item three
but the converted pdf does not convert the list correctly. Instead it looks like:
1. item one
1. item two
1. item three
Attached an example. I’d be willing to look at it when I have a chance but wanted to document this behavior first. This behavior appeared in the debug html as well.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Incorrect conversion of numbered list · Issue #445 - GitHub
Described this issue here Basically, I have a numbered list with some markdown using back ticks in between each item, seen here.
Read more >Fixing numbered lists in Word
In the Resource and User Guides, each new process is formatted using a numbered list. In Word, these lists are mapped to the...
Read more >Problem with numbered list - CreativePro Network
If you only have one type of numbers, you can Convert to Ordered Lists. But if you are using numbered lists for Chapters,...
Read more >Bulleted items or numbered items become misaligned when ...
This behavior occurs because bulleted items and numbered items use an internal tab to align the text with the bullet or with the...
Read more >CWE-681: Incorrect Conversion between Numeric Types (4.9)
Common Weakness Enumeration (CWE) is a list of software weaknesses.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @tivie, thanks so much for stopping by and explaining this in such great detail. I apologise for not reading the spec initially to check this. Seems we were also fooled by github’s implementation of the planned / non-standard feature.
In light of that information, the solution in the TLDR seems to work just fine with mdpdf so I’m going to close this issue.
Also thanks for raising it @djm158, I learned something new from it.
TL;DR;
It’s not a bug in showdown, but rather a problem with the input. List’s Sub-blocks must be indented 4 spaces (or they will be treated as a “root block”)
Explanation
A bunch of things are happening here:
List’s Sub-blocks must be indented 4 spaces
According to the original markdown spec a sub-block, in a list, must be indented to be considered part of the list.
Example: (see showdown’s live demo)
input MD:
generated HTML:
In your md source, your code blocks are not indented so each list item is interpreted as “new” list. see demo
This happens in every markdown implementation, even in github’s implementation. ([see babelmark2 for comparison in implementations][bb2_1])
The numbering in lists is not important
According to the same spec:
Your input “seems” to work in github’s
The issue, however, arises when you consider the next paragraph the spec:
Github supports this “planned feature” where the number you put in the first list item counts as the starting value of the ordered list. For instance, copy/paste the following markdown in a comment here in github and click preview:
Input:
Output:
This feature is non standard and not implemented in showdown (although it’s planned for a soonish future release),
So, in your MD, every list item is considered a new list, rather than a list item. But since github supports defining the starting number of ordered lists, the output seems correct (although it’s not)
[bb2_1]: https://johnmacfarlane.net/babelmark2/?normalize=1&text=1.+Does+every+software+system+have+an+architecture%3F++Why+or+why+not%3F ``` ________________________________________________________________________ ``` 2.+You+are+designing+a+climate+control+system%2C+which+accepts+inputs+from+a+variety+of+distributed+sensors+(e.g.%2C%0AOf+the+architectural+styles+listed+in+Tsui+et+al%2C+which+one+would+be+best+for+this+kind+of+system%3F++Why%3F%0A%0A%60%60%60%0A________________________________________________________________________%0A%0A________________________________________________________________________%0A%60%60%60