mojombo/github-flavored-markdown

Insert the code block causes the ordered list of discontinuity

shepherdlazy opened this issue · 3 comments

a. Example Normal

  1. The first
    this is contents of.
    Random ro = new Random();
  2. Second
  3. Third

b. Example Abnormal

  1. The first
    this is contents of.
Random ro = new Random();
  1. Second
  2. Third

Source Code

#### a. Example Normal
1. The first    
 this is contents of.    
`Random ro = new Random();`
2. Second
3. Third

#### b. Example Abnormal
1. The first    
 this is contents of.  
\```csharp
Random ro = new Random();
\```
2. Second
3. Third

Markdown requires new block-level elements in a list item to be indented by 4 spaces. So in order for the code block to not reset the list, you need to add 4 spaces before the backticks.

b. Example Abnormal

  1. The first
    this is contents of.
    csharp Random ro = new Random();
  2. Second
  3. Third

Source:

#### b. Example Abnormal
1. The first    
 this is contents of.  
    ```csharp
Random ro = new Random();
\```
2. Second
3. Third

@mdiep Thank you! but I inserted in the code segment of 4 spaces will make the code block cannot indentation and bright.

b. Example Abnormal

  1. The first
    this is contents of.
    csharp int i=0; Random ro = new Random();
  2. Second
  3. Third

source code

#### b. Example Abnormal
1. The first    
 this is contents of.  
    ```csharp
int i=0;
Random ro = new Random();
\```
2. Second
3. Third

I didn't think of it at the time, but that's because there needs to be a blank line between the list item's paragraph and the code block. Otherwise, the code black is considered to be a code span and is part of the paragraph.

b. Example Abnormal

  1. The first
    this is contents of.

    Random ro = new Random();
  2. Second

  3. Third

Source Code

#### b. Example Abnormal
1. The first
this is contents of.

    ```csharp
Random ro = new Random();
\```
2. Second
3. Third