2

I have a Markdown enumeration:

  1. sdsdf
  2. sdfsdf

some code 3. sdfsdf

The 3. is shown as one because of the code block.

How can I insert a code block in one of the enumeration steps and let the enumeration counter continue correctly after the counter?

1

1 Answer 1

5

Indent the code block by four additional spaces to show that it's part of the preceding list item:

1. sdsdf
1. sdfsdf

        function foo() {
            // do something
        }

1. sdfsdf

The extra four spaces are required to include the code block in the list item:

To put a code block within a list item, the code block needs to be indented twice - 8 spaces or two tabs:

* A list item with a code block:

        <code goes here>
Sign up to request clarification or add additional context in comments.

6 Comments

In this case the intentions of the code block are gone.
@stephan1001, your comment is unclear. What does "the intentions of the code block are gone" mean?
@stephan1001, not at all. Just indent all code lines by an additional four spaces. See my updated answer.
Yes I know but why do I need the additional four spaces?
@stephan1001, so the code block is included in the list item. It's part of the spec. I've updated my answer again.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.