Vertical bar symbol within a markdown table

at. picture at. · Apr 13, 2018 · Viewed 9.8k times · Source

Markdown tables use vertical bars as field separators, but I need to write a vertical bar within some cells. Is this possible? I'm using GFM (GitHub Flavored Markdown).

Can I escape the vertical bar somehow?

This is not on GitHub, it's through Docusaurus. I don't know which parser Docusaurus uses, but none of the following work:

  • | - | just gets displayed (the & is escaped)
  • <code> - Any html is displayed (the < is escaped)
  • \| - | still acts as a table cell delimiter

UPDATE:

&#124; works if I don't have it inside backticks. So, at least for now, I simply un-backtick the vertical bar. For example, a | b becomes a|b

Answer

Yangshun Tay picture Yangshun Tay · Apr 14, 2018

Docusaurus maintainer here! Docusaurus uses Remarkable for parsing Markdown.

As you pointed out in your question, you can write this in your table - &#124; and it will render as |.

If you want it to appear with monospaced styling, wrap it in <code>&#124;</code> instead of using backticks. You will have to write HTML and not markdown to get it to work.

Refer to line 30 of Reason Cheatsheet. I recently fixed a similar issue in the Reason docs.

## Boolean

| JavaScript                                            | Reason                                         |
| ----------------------------------------------------- | ---------------------------------------------- |
| `true`, `false`                                       | `true`, `false` \*                             |
| `!true`                                               | Same                                           |
| <code>&#124;&#124;</code>, `&&`, `<=`, `>=`, `<`, `>` | Same                                           |
| `a === b`, `a !== b`                                  | Same                                           |
| No deep equality (recursive compare)                  | `a == b`, `a != b`                             |
| `a == b`                                              | No equality with implicit casting (thankfully) |

becomes:

Reason Table