Markdown: continue numbered list

前端 未结 12 1620
予麋鹿
予麋鹿 2020-12-04 04:39

In the following markdown code I want item 3 to start with list number 3. But because of the code block in between markdown starts this list item as a new list.

12条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 05:36

    Notice how in Macmade's solution, you can see an extra line of code above the "Code block".

    Here are two better solutions:

    1. Indent the code block by an extra 4 spaces (so usually 8, in this nested list example, 12). This will put the code in a

       element. On SO, you can even specify syntax highlight with a
      indented by 4 spaces (+1 here due to the nested list).

      1. item 1
      2. item 2

        Code.block('JavaScript', maybe)?
        
      3. item 3

    2. Or, just put the Code block within backticks and indent by 4 spaces (here, 1 extra because of the nested list). You'll get a regular indented text paragraph, with a element inside it. This one you can't syntax-highlight:

      1. item 1
      2. item 2

        Code block

      3. item 3

    Note: you can click "edit" on this answer to see the underlying Markdown code. No need to save ;)

提交回复
热议问题