Markdown/Github:作为列表子项的代码块的语法突出显示
在Github/MD中,如果我们想在列表的子级时启用代码块,我们需要用8个空格来表示它。
但是如何让该代码块具有语法高亮功能呢?
以下代码无法按预期工作...
1. foo
```python
print 'bar'
```
2. bar
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有空格应该可以工作:来自 GitHub 帮助页面:
如 hilz 的 中所示回答下面,您需要使用与列表相同的缩进级别 + 2 个空格来缩进 ````。
代码块的内容不需要缩进。
请参阅此要点作为示例:
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.
See this gist as an example:
要使带有语法突出显示的代码块愉快地嵌入到列表中,请将代码块之前和之后的标记行嵌入到附加段落的适当缩进级别,然后照常进行。例如:
将每个代码块缩进到适当的深度并保持索引的完整性。
To get code blocks with syntax highlighting embedded happily in a list, embed the markup lines that come before and after the code block to the appropriate level of indenting for an additional paragraph, then proceed as normal. For example:
indents each code block to the appropriate depth and maintains the integrity of the indexes.
现在,您必须执行以下操作:
也就是说,确保语法突出显示的代码与反引号在同一列中开始。您还必须稍微帮助编号,因为在代码块之后它似乎会丢失计数。
另请参阅:https://gist.github.com/therealbstern/9cb0dfc7f0f4b76a062247676aed341b
Nowadays, you have to do the following:
That is, make sure your syntax-highlighted code starts in the same column as the backticks. You also have to help the numbering out a little bit, because it appears to lose count after code blocks.
See also: https://gist.github.com/therealbstern/9cb0dfc7f0f4b76a062247676aed341b