Ehsan
Ehsan

Reputation: 137

How to show "||" operator in a Markdown table?

I'm trying to show || in a GitHub readme page, but these | are used for creating columns in the table. How can I use this || so it doesn't mean a column?

op dec
&& AND
OR

I tried \ before the | character, but it still didn't work.

Upvotes: 1

Views: 299

Answers (1)

Alexander
Alexander

Reputation: 63271

You need an escaping backslash (\) before each pipe character (any un-escaped pipe would be treated as part of the table), like so:

| Operator | Description |
|----------|-------------|
| &&       | AND         |
| \|\|     | OR          |

Result:

Operator Description
&& AND
|| OR

Although I'd suggest marking them with inline code blocks:

Markdown:

| Operator | Description |
|----------|-------------|
| `&&`     | AND         |
| `\|\|`   | OR          |

(It looks wrong on StackOverflow, but works correctly with GitHub's parser.)

Upvotes: 1

Related Questions