How do you create a numbered checklist (AKA task list) in GitHub flavored Markdown?

36 views Asked by At

I'm trying to create a numbered checklist in this GitHub issue I created. I found this blog article explaining how to create an unordered checklist, but is there a way to create an ordered checklist?

My first thought was to try this:

1. [ ] If `TestRestTemplate` can be used with spring-data-rest, please provide examples of using it with response bodies more complex than `String` or `Map<?, ?>`. E.g., a `Person` class.
2. [ ] Please also include a `postForEntity` <s>and/or `putForEntity`</s>(`putForEntity` doesn't exist) example, because I see a lot of people struggling to make requests that send a complex class, e.g., `Person`, in the request body.
3. [ ] If `TestRestTemplate` is the *wrong* tool for the job, please recommend the right tool or a better tool. This might already be documented, but I've been unable to find it.

But that removes the numbers from the bulleted list:

Enter image description here

Through experimentation, this was the closest I could get:

1. - [ ] If `TestRestTemplate` can be used with spring-data-rest, please provide examples of using it with response bodies more complex than `String` or `Map<?, ?>`. E.g., a `Person` class.
2. - [ ] Please also include a `postForEntity` <s>and/or `putForEntity`</s>(`putForEntity` doesn't exist) example, because I see a lot of people struggling to make requests that send a complex class, e.g., `Person`, in the request body.
3. - [ ] If `TestRestTemplate` is the *wrong* tool for the job, please recommend the right tool or a better tool. This might already be documented, but I've been unable to find it.

but the whitespace between the number and the checkbox looks wrong.

Enter image description here

Is there a better way to create a numbered checklist in GitHub flavored Markdown?

1

There are 1 answers

3
Waylan On
1. [ ] If `TestRestTemplate` can be used with spring-data-rest, please provide examples of using it with response bodies more complex than `String` or `Map<?, ?>`. e.g., a `Person` class.
2. [ ] Please also include a `postForEntity` <s>and/or `putForEntity`</s>(`putForEntity` doesn't exist) example, because I see a lot of people struggling to make requests that send a complex class, e.g., `Person`, in the request body.
3. [ ] If `TestRestTemplate` is the *wrong* tool for the job, please recommend the right tool or a better tool. This might already be documented, but I've been unable to find it.

Just replace the bullet list marker (-) with an ordered list marker (1.). Note that the specification specifically states:

A task list item is a list item where the first block in it is a paragraph which begins with a task list item marker and at least one whitespace character before any other content.

And a list item is defined as:

A list is an ordered list if its constituent list items begin with ordered list markers, and a bullet list if its constituent list items begin with bullet list markers.

So, if you put those two together, then you take the appropriate list marker and follow it by the task list item marker. I realize that the specification does not show any examples of ordered task lists, but a quick test in a GitHub comment shows that it works.

I should note that while the above does in fact result in an ordered list (ol), GitHub currently has styles in place which will hide the list item markers for all task lists items (regardless of whether they are ordered or unorder lists). See the screenshot below of my browser's "inspect" tool.

Inspect tool

As you can see, the list is a ol, but a CSS rule is defined setting list-style-type: none; for any .task-list-item. As GitHub does not allow users to override CSS rules for security reasons, currently there is no way to get an ordered task list to display the markers (item numbers) on their website...

That is unless you use the hack of using both list marker types together. When doing that, you were actually nesting one list item inside another list item. You have a outer ordered list item, which is not a task-list-item, so it retains its list item marker. And then you have an unordered list item nested inside it and that unordered list item then contained the checkbox and content. The nested items also explains the extra whitespace you were seeing. Again, without the ability to alter GitHub's CSS rules, there is no way to remove the extra whitespace.