将代码块的语法突出显示为列表的子代

将代码块的语法突出显示为列表的子代

本文介绍了Markdown / Github:将代码块的语法突出显示为列表的子代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Github / MD中,如果我们希望在代码块是列表子时启用它,我们需要以8个空格来表示它。



但是如何使该代码块具有语法高亮功能?



以下代码无法按预期运行......

  1. foo 

```python
print'bar'
```

2. bar


解决方案
 ```python 
print'bar '
```

without spaces should work:from 的,你需要缩进````缩进级别+ 2空格,而不是你的列表。

c的内容ode块不需要缩进

  1。 foo 

````python
print'bar'
```

1.

`` ``python
print'bar'
````

a href =https://gist.github.com/VonC/10666727 =nofollow noreferrer>以此为例:


In Github/MD, if we want to enable code block when it is a child of list, we need to intent it by 8 spaces.

But how to make that code block has the syntax highlighting feature?

The following code does not work as expected...

    1. foo

             ```python
                print 'bar'
             ```

    2. bar
解决方案
```python
print 'bar'
```

without spaces should work: from GitHub help page:


As illustrated in hilz's answer below, you need to indent the ```` with the same indentation level + 2 spaces than your list.
The content of the code block doesn't need to be indented.

1. foo

  ````python
print 'bar'
  ````

  1.

    ````python
print 'bar'
    ````

See this gist as an example:

这篇关于Markdown / Github:将代码块的语法突出显示为列表的子代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 15:29