gpt4 book ai didi

Github markdown,表格单元格中代码块的语法高亮

转载 作者:行者123 更新时间:2023-12-03 10:38:53 24 4
gpt4 key购买 nike

Markdown 具有管道表语法,但在某些情况下还不够。

| table | syntax | without multiline cell content |

因此,我们可以使用 HTML 表格标签。

<table>
<tr>
<td>
```csharp
const int x = 3;
const string y = "foo";
readonly Object obj = getObject();
```
</td>
<td>
```nemerle
def x : int = 3;
def y : string = "foo";
def obj : Object = getObject();
```
</td>
<td>
Variables defined with <code>def</code> cannot be changed once defined. This is similar to <code>readonly</code> or <code>const</code> in C# or <code>final</code> in Java. Most variables in Nemerle aren't explicitly typed like this.
</td>
</tr>

但是前段时间语法高亮被破坏了,这 wiki page现在看起来很丑。有想法该怎么解决这个吗?

最佳答案

您可以使用 <pre>正如 teh_senaus 所说,在表格中。但是如果你这样做,语法高亮将不起作用......或者会吗?

通过随机实验,我发现 GitHub 允许使用 <pre lang="csharp"> 指定它。 .这与 ```csharp 的效果相同。将语法高亮设置为 C#。

这在 GitHub 的帮助中心和 linguist 中都没有真正记录。的文档。但它有效,即使在 table 内部。

因此,对于您的示例表,新代码如下:

<table>
<tr>
<td>
<pre lang="csharp">
const int x = 3;
const string y = "foo";
readonly Object obj = getObject();
</pre>
</td>
<td>
<pre lang="nemerle">
def x : int = 3;
def y : string = "foo";
def obj : Object = getObject();
</pre>
</td>
<td>
Variables defined with <code>def</code> cannot be changed once defined. This is similar to <code>readonly</code> or <code>const</code> in C# or <code>final</code> in Java. Most variables in Nemerle aren't explicitly typed like this.
</td>
</tr>

关于Github markdown,表格单元格中代码块的语法高亮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21878143/

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