4

Is it possible to display a numbered list that is followed by a code block? It seems that an answer with this structure breaks the formatting applied via Markdown.

Here is an example to illustrate the point, with the broken formatting:

  1. We will have a first point

  2. And a second point as an alternative to the first

  3. And finally a catch-all in case neither the of the first options apply

    !/bin/bash

    # echo "I intend that this four-line block should be displayed as code" echo "But it isn't."

1 Answer 1

3

You need to indent it with eight spaces instead of four:

  1. Numbered list

    Code block
    Line 2
    

Indenting a line right after a list indicated that it's part of that list item. If you make a new, non-indented line after the list, you'll see it's not part of that list:

  1. Numbered list

Next line

As compared to:

  1. Numbered list

    Next line (4 space indent)

  2. Next list item

Four spaces makes that line part of the previous list item. Eight spaces is four spaces to include the line with the preceding list, and four more to make it code

4

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .