Format to add standard code blocks within Markdown lists

可紊 提交于 2019-12-11 09:50:08

问题


I've found that I can't get code blocks within numbered lists.

For example, when I add a code block by indenting by four spaces normally like below:

1. Do the first thing

    $ git stuff
    $ git other stuff 

2. second thing:

    $ git more stuff

it comes out like this, where the $ git lines are normal text and are not formatted as code:

  1. Do the first thing

    $ git stuff $ git other stuff

  2. second thing:

    $ git more stuff

I can use the backticks to do it, i.e.

1. Do the first things

    `$ git stuff`  
    `$ git other stuff` 

2. second thing:

    `$ git more stuff`

but I would like to do the blocks 'normally' (4 space indent) if I can.


回答1:


Per the documentation you need to do extra indentation; +4 spaces or +1 tab (8/2, respectively, from column 0).

1. Item 1

        $git stuff
        $git other stuff

2. Item 2

        $git more stuff

Those newlines are necessary.



来源:https://stackoverflow.com/questions/10271188/format-to-add-standard-code-blocks-within-markdown-lists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!