When I create a numbered list that contains code blocks all the items in the list get numbered as 1.
When using any other markdown processor the items are numbered correctly.
Example:
1. Create a new logical volume group ([docs](https://docs.ansible.com/ansible/latest/collections/community/general/lvg_module.html))
`` ```
- name: Create a volume group on top of /dev/sdb with physical extent size = 32MB
community.general.lvg:
vg: vg.storage
pvs: /dev/sdb1
pesize: 32
`` ```
2. Create a logical volume in your logical volume group ([docs](https://docs.ansible.com/ansible/latest/collections/community/general/lvol_module.html#ansible-collections-community-general-lvol-module))
`` ```
- name: create logical volume
community.general.lvol:
vg: vg.storage
lv: data
size: 10g
`` ```
Renders both items as item 1 (ignore the extra double ticks, its the only way I could make the code block render correctly in this post.)
Different Markdown processors handle this in various ways. To make the code-block part of the list item with Jekyll’s default Kramdown processor, it should be indented by 3 spaces:
1. Create a new logical volume group
```
- name: Create a volume group on top of /dev/sdb
community.general.lvg:
vg: vg.storage
pvs: /dev/sdb1
pesize: 32
```
2. Create a logical volume in your logical volume group
```
- name: create logical volume
community.general.lvol:
vg: vg.storage
lv: data
size: 10g
```
Well dang, that’s awkward but it works. Thanks for the assist!
I never used 3 spaces on and have been fine with 4. I know that 2 specifically breaks here so I avoid 2 spaces in general
1. Create a new logical volume group
```yaml
- name: Create a volume group on top of /dev/sdb
community.general.lvg:
vg: vg.storage
pvs: /dev/sdb1
pesize: 32
```
Result
- Create a new logical volume group
- name: Create a volume group on top of /dev/sdb
community.general.lvg:
vg: vg.storage
pvs: /dev/sdb1
pesize: 32
The whitespace is unnecessary but you can add it within the points.
The key part is indenting items so that it goes to 1, 2, etc. Because if you don’t indent by 4 then it thinks each is 1., 1., etc.
Oh and use 4 spaces to make text into a code block in forum answers. Instead of backticks
Abc
```
Def
```
Result
Abc
```
Def
```
In the case of @philskents sample, the correct answer is 3 spaces (assuming Jekyll 4.2 with default Kramdown processor). With Kramdown, using 4 spaces will cause the code blocks to have an extra leading space, which probably makes the sample code syntactically incorrect YAML.
The generalized answer is to indent as much as the first character in the list item. For example, a list item of 100. A...
will require 5 spaces – at least according to the CommonMark List Item Spec, which many markdown processors follow.
Note that this forum uses a different markdown processor, so it handles extra spaces before code-blocks differently (it strips them), so 4 spaces works. For this corner case, Kramdown departs from the CommonMark spec in its handling of spaces before code fences.
1 Like
Oh yeah I tried out on my site now. 4 spaces didn’t work
1 Like