Markdown / Github:将代码块的语法突出显示为列表的子代 [英] Markdown/Github: syntax highlighting of code block as a child of a list
问题描述
但是如何使该代码块具有语法高亮功能?
以下代码无法按预期运行......
1. foo
```python
print'bar'
```
2. bar
```python
print'bar '
```
without spaces should work:from GitHub帮助页面:
<只需将代码块封装在```和中,您就不需要手动缩进来触发代码块。
如 hilz 的 answer ,你需要缩进````缩进级别+ 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:
Just wrap your code blocks in ``` and you won't need to indent manually to trigger a code block.
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'
````
这篇关于Markdown / Github:将代码块的语法突出显示为列表的子代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!