Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
661 views
in Technique[技术] by (71.8m points)

github - How to escape a pipe char in a code statement in a markdown table?

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.

Here is what I want:

      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?

Note that I already tried to use the | HTML code, but it produces a |= y;.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As of March 2017 using escaped pipes is much easier: | See other answers.

If you remove the backticks (`), using the | hack works

      a     |  r  
------------|-----
 `a += x;`  |  r1
 a |= y;  |  r2

and produces the following output

enter image description here

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

generating the following output

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...