gpt4 book ai didi

markdown - Markdown 中有两列

转载 作者:行者123 更新时间:2023-12-02 18:39:51 42 4
gpt4 key购买 nike

我想编写一份编码标准规范文档,其中包含编码示例。每条规则都应该有一个编号、描述和示例。

例如,这是规则 1:

# Rule 1
Description for rule 1.

## Good
```c
int foo (void)
{
int i;
}
```

## Bad
```c
int foo (void) {
int i;
}
```

根据每条规则,我想生成一个带有全局目录的 PDF 或 HTML 页面。

如何编写兼容 Markdown 的代码,可以用语法着色表示水平对齐的代码块?

像这样(这是一张图片):

enter image description here

我知道我可以在 Markdown 文档中使用 HTML,因此我可以编写如下内容:

<good>
```c
int foo (void)
{
int i;
}
```
</good>
<bad>
```c
int foo (void) {
int i;
}
```
</bad>

然后处理数据(我仍然不知道如何)

markdown -> own-tags-processing -> LaTeX -> pdf
markdown -> own-tags-processing -> HTML

有没有更好的方法来水平对齐两个代码块?

最佳答案

虽然这并不适用于所有 Markdown 方言,但我让它可以与 GitLab、GitHub 和 mdBook 一起使用。

基本上,您通过 HTML 创建表格。 Markdown 和 HTML 不能很好地混合,但如果用空格包围 Markdown,有时可以识别 Markdown。

https://docs.gitlab.com/ee/user/markdown.html#inline-html

<table>
<tr>
<th> Good </th>
<th> Bad </th>
</tr>
<tr>
<td>

```c++
int foo() {
int result = 4;
return result;
}
```

</td>
<td>

```c++
int foo() {
int x = 4;
return x;
}
```

</td>
</tr>
</table>

关于markdown - Markdown 中有两列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30514408/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com