Search code examples
markdowngithub-flavored-markdown

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.


Solution

  • 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.)