How to disply two markdown code blocks side by side

你说的曾经没有我的故事 提交于 2021-01-26 03:15:36

问题


I would like to display two blocks of a source codes side by side -before refactoring and after. Is it possible to create two code blocks side by side? If not then what is the alternative solution?


回答1:


There is no way to create multi-line code blocks in a single table cell using bare Markdown syntax - but you can use verbatim HTML to accomplish this. Here is an example two-column table with side-by-side code (note that this HTML goes side-by-side with the rest of your 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>

which is rendered as:

two-column table in markdown



来源:https://stackoverflow.com/questions/35381425/how-to-disply-two-markdown-code-blocks-side-by-side

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!