Markdown: continue numbered list

前端 未结 12 1574
予麋鹿
予麋鹿 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:38

    Use four spaces to indent content between bullet points

    1. item 1
    2. item 2
    
        ```
        Code block
        ```
    3. item 3
    

    Produces:

    1. item 1
    2. item 2

      Code block

    3. item 3
    0 讨论(0)
  • 2020-12-04 05:38

    Macmade's solution doesn't work for me anymore on my Jekyll instance on Github Pages anymore but I found this solution on an issue for the kramdown github repo. For OP's example it would look like this:

    1. item 1
    2. item 2
    
    ```
    Code block
    ```
    
    {:start="3"}
    3. item 3
    

    Solved my issues handily.

    0 讨论(0)
  • 2020-12-04 05:38

    If you want to have text aligned to preceding list item but avoid having "big" line break, use two spaces at the end of a list item and indent the text with some spaces.

    Source: (dots are spaces ;-) of course)

    1.·item1··
    ····This is some text
    2.item2
    

    Result:

    1. item1
      This is some text
    2. item2
    0 讨论(0)
  • 2020-12-04 05:39

    Put the list numbers in parentheses instead of followed by a period.

    (1) item 1
    (2) item 2 code block (3) item 3

    0 讨论(0)
  • 2020-12-04 05:40

    If you happen to be using the Ruby gem redcarpet to render Markdown, you may still have this problem.

    You can escape the numbering, and redcarpet will happily ignore any special meaning:

    1\. Some heading
    
    text text
    text text
    
    text text
    
    2\. Some other heading
    
    blah blah
    
    more blah blah
    
    0 讨论(0)
  • 2020-12-04 05:43

    As an extension to existing answers. For those trying to continue a numbered list after something other than a code block. For example a second paragraph. Just indent the second paragraph by at least 1 space.

    Markdown:

    1. one
    2. two
    
     three
    3. four
    

    Output:

    1. one

    2. two

      three

    3. four

    0 讨论(0)
提交回复
热议问题