question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect conversion of numbered list

See original GitHub issue

Tried 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.

quiz4.pdf

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
BlueHatbRitcommented, Oct 16, 2017

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.

1reaction
tiviecommented, Oct 17, 2017

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:

1. Does every software system have an architecture?  Why or why not?

    ```
    _________________________________________________________________________
    _________________________________________________________________________
    ```

2. You are designing a climate control system, which accepts inputs from a variety...

    ```
    _________________________________________________________________________
    _________________________________________________________________________
    ```

generated HTML:

<ol>
<li><p>Does every software system have an architecture?  Why or why not?</p>
<pre><code>_________________________________________________________________________
_________________________________________________________________________</code></pre></li>
<li><p>You are designing a climate control system, which accepts inputs from a variety...</p>
<pre><code>_________________________________________________________________________
_________________________________________________________________________</code></pre></li>
</ol>

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])

<ol>
<li>Does every software system...</li>
</ol>
<pre><code>_____________________________________________________________</code></pre>
<ol>
<li>You are designing a climate control system...</li>
</ol>

The numbering in lists is not important

According to the same spec:

It’s important to note that the actual numbers you use to mark the list have no effect on the HTML output Markdown produces. (…) The point is, if you want to, you can use ordinal numbers in your ordered Markdown lists, so that the numbers in your source match the numbers in your published HTML. But if you want to be lazy, you don’t have to.

Your input “seems” to work in github’s

The issue, however, arises when you consider the next paragraph the spec:

If you do use lazy list numbering, however, you should still start the list with the number 1. At some point in the future, Markdown may support starting ordered lists at an arbitrary number.

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:

2. foo
6. bar
2. baz
9. bazinga

Output:

  1. foo
  2. bar
  3. baz
  4. bazinga

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found