Let's suppose we have the following table of params and values in markdown where we want to use the "|
" (pipe) character inside a table cell:
param | value ---------|--------------------- `format` | `json`|`xml`|`html`
Escaping the Pipe Character
In some platforms you can directly escape the pipe character in markdown using a backslash like so:
param | value ---------|---------------------- `format` | `json`\|`xml`\|`html`
Using the ASCII Code in Place of the Pipe Character
The pipe character is represented by |
(or |
) in ASCII, which you can use in place of the pipe character like so:
param | value ---------|---------------------- `format` | `json`|`xml`|`html`
However, this won't work if the pipe character is used inside backticks. To demonstrate this, let's consider the following table of regular expressions as an example:
type | regex pattern -------------|---------------------------- `first_name` | `[a-zA-Z]` `job_role` | `manager|designer|internee`
To correctly render the pattern for "job_role
" we can replace the backticks with "<code></code>
" in the following way:
type | regex pattern -------------|---------------------------- `first_name` | `[a-zA-Z]` `job_role` | <code>manager|designer|internee</code>
Although, it might look a little messy, it solves the problem. Before using this method though, be sure to try and see if the platform you're using markdown in supports escaping the pipe character or not (as that would be a better way).
This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.