Reputation: 574
Is it possible to make a numbered list of code blocks in Markdown? This is a list where each list item is a code block; there is no other text.
If it is possible, how? If not, why?
My use case, for anyone curious about context, is formatting coding exercises in a tutorial. Some exercises ask the reader to look at multiple code examples. These coding examples are presented in a numbered list. They need to be numbered as these numbers will be used to refer to the section of the exercise.
I am using Remarkable with Github-flavored Markdown. I am now wondering if my issue could be related to this particular software, because I attempted the working example in @dxiv's answer and got a divergent result. I can see their Markdown works in the StackOverflow comment, but Remarkable renders it with the code blocks missing newlines. For example:
abc
def
...is the expected output, but Remarkable renders as:
abc def
Upvotes: 2
Views: 1919
Reputation: 17658
The following appears to work, see source for the raw text in all cases.
1. ```
abc
def
```
For example.
abc
def
123
456
ghi
jkl
mno
pqr
[ EDIT ] Seeing that Remarkable has an online demo, that one appears to render lists of code blocks similarly to SO above, see for example this snippet (link was too long to post in a comment).
Upvotes: 1