How to hide char pipe in code instruction in markdown table?

On GitHub, I want to create a table containing snippets of code in Markdown. It works fine, except when I put a char pipe (i.e. |) between backward characters (i.e. `).

Here is what I want:

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

The problem is that the vertical bar in the code expression of the second row is interpreted as a column delimiter. Then the rendering of the table looks pretty ugly. How could I avoid this?

Note that I have already tried using the HTML | but it creates a |= y; .

+45
github escaping pipe markdown
Jun 26 '13 at 12:24
source share
3 answers

If you remove the inverse elements ( ` ), use | hack works

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

and produces the following output

enter image description here

Alternatively, you can replace backticks ( ` ) with <code></code> markup, which better fixes problems while maintaining rendering

  a | r ------------|----- `a += x;` | r1 <code>a &#124;= y;</code> | r2 

generates the following output

enter image description here

+71
Jun 26 '13 at 12:43 on
source share

As of mid-2017, the pipe can simply be reset with a backslash, for example: \|

This works both inside and outside backticks.

HTML code can now be used again, but only outside of backlinks.

Previous answer:

As of March 2017, the accepted answer stopped working because GitHub changed their markdown analyzer . Using another unicode character that resembles a pipe seems only now, for example:

| (U + 01C0, latin letter click)

| (U + 2223, character divides)

⎮ (U + 23AE, integral extension)

+5
Mar 28 '17 at 13:29
source share

You can avoid | in a table in GFM using \ , for example:

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

See https://github.github.com/gfm/#example-191 or https://github.com/dotnet/csharplang/pull/743 for an example.

0
Jul 15 '17 at 19:31
source share



All Articles