如何在降价表中的代码语句中转义管道字符? [英] How to escape a pipe char in a code statement in a markdown table?

查看:20
本文介绍了如何在降价表中的代码语句中转义管道字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 GitHub 上,我想构建一个包含 Markdown 代码片段的表格.它工作正常,除非我在反引号(即`)字符之间放了一个管道字符(即 | ).

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;.

推荐答案

截至 2017 年 3 月,使用转义管道要容易得多:| 查看其他答案.

如果您删除反引号 (`),则使用 | hack 作品

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 &#124;= y;</code>  |  r2

生成以下输出

这篇关于如何在降价表中的代码语句中转义管道字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆