我想要将一个源代码的两个块并排展示——重构前和重构后。是否可以创建两个并排的代码块?如果不行,那么有什么替代方案吗?
我想要将一个源代码的两个块并排展示——重构前和重构后。是否可以创建两个并排的代码块?如果不行,那么有什么替代方案吗?
使用原始Markdown语法无法在单个表格单元格中创建多行代码块,但您可以使用原样的HTML来实现。这是一个示例双列表格,其中包含并排显示的代码(请注意,此HTML与您的Markdown一起并排显示):
# Document Title
The usual [Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)
does not cover some of the more advanced Markdown tricks, but here
is one. You can combine verbatim HTML with your Markdown.
This is particularly useful for tables.
Notice that with **empty separating lines** we can use Markdown inside HTML:
<table>
<tr>
<th>Json 1</th>
<th>Markdown</th>
</tr>
<tr>
<td>
<pre>
{
"id": 1,
"username": "joe",
"email": "joe@example.com",
"order_id": "3544fc0"
}
</pre>
</td>
<td>
```json
{
"id": 5,
"username": "mary",
"email": "mary@example.com",
"order_id": "f7177da"
}
```
</td>
</tr>
</table>
这将呈现为:
# Document Title
The usual [Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)
does not cover some of the more advanced Markdown tricks, but here
is one. You can combine verbatim HTML with your Markdown.
This is particularly useful for tables.
Notice that with **empty separating lines** we can use Markdown inside HTML:
<table>
<tr>
<th>Json 1</th>
<th>Markdown</th>
</tr>
<tr>
<td>
```json
{
"id": 1,
"username": "joe",
"email": "joe@example.com",
"order_id": "3544fc0"
}
```
</td>
<td>
```json
{
"id": 5,
"username": "mary",
"email": "mary@example.com",
"order_id": "f7177da"
}
```
</td>
</tr>
</table>
示例:https://gist.github.com/nottheswimmer/7837eec10fac0d1197fc5a8bfc0b96f3