Skip to content

[STYLE] Newlines before indented code blocks belonging to list items #108

@kolkhis

Description

@kolkhis

A very common pattern we use in these books:

1. Do this thing

   ```bash
   echo "some cmd"
   \```

(ignore the \, only needed for issue formatting)

This code block should be indented to the same level as the text in the list item. However, the newline before it causes MkDocs to believe that it is completely separate from the list.

This formatting also causes MkDocs' markdown parser to read that as the end of the list, which causes subsequent list items to be reset (for ordered lists, the number resets to 1).

Any occurrences of this pattern should be fixed with:

1. Do this thing
   ```bash
   echo "some cmd"
   \```

Note that there is no newline between the list text and the start of the code block.

A quick example of this behavior:

Image

The lines without the newline have the code blocks indented correctly. The one that has a newline does not indent the code block and resets the list back to 1.

Note that this does not only apply to code blocks. The same can be said for images or just regular text. Any newline followed by a non-list item causes the list to reset.

Metadata

Metadata

Assignees

Labels

adminRelated to the Linux Administration courseautomationRelated to the ProLUG Linux Automation coursebugSomething isn't workingsecurityRelated to the Security Engineering course

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions