如何在markdown表中的代码语句中转义管道char? [英] How to escape a pipe char in a code statement in a markdown table?
问题描述
在GitHub上,我想在Markdown中构建一个包含代码片段的表格。它工作正常,除非我在反驳(即`)字符之间放一个管道char(ie |)。
On GitHub I want to build a table containing pieces of code in Markdown. It works fine except when I put a pipe char (i.e. | ) between the backtick (i.e. ` ) chars.
这是我想要的:
a | r
------------|-----
`a += x;` | r1
`a |= y;` | r2
问题是第二行的代码语句中的竖线被解释为列分隔符。那么桌面渲染看起来很丑陋。如何避免这种情况?
The problem is that the vertical bar in the code statement of the second line is interpreted as a column delimiter. Then the table rendering looks pretty ugly. How could I avoid that?
请注意,我已经尝试使用|
HTML代码,但是它生成 a| = y;
。
Note that I already tried to use the |
HTML code, but it produces a |= y;
.
推荐答案
如果你删除反引号(`),使用|
hack works
If you remove the backticks (`), using the |
hack works
a | r
------------|-----
`a += x;` | r1
a |= y; | r2
并生成以下输出
或者,您可以替换具有< code>< / code>
标记的反引号(`)通过保留渲染来更好地修复问题>
Alternatively, you can replace the backticks (`) with a <code></code>
markup which fixes the issues more nicely by preserving the rendering
a | r
------------|-----
`a += x;` | r1
<code>a |= y;</code> | r2
生成以下输出
< img src =https://i.stack.imgur.com/PJrqV.pngalt =在此输入图像说明>
这篇关于如何在markdown表中的代码语句中转义管道char?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!