Skip to content
FileMyLove

Keep a literal pipe inside a Markdown table cell when converting to Word

Write a vertical bar as table content without accidentally splitting a cell, then verify the DOCX result.

By FileMyLove Team2 min read

A value such as A|B belongs in one cell, but the vertical bar is also the separator used by a Markdown pipe table. Distinguish the bar that is data from the bars that define columns. Changing the Word column width cannot repair a source value split at the wrong place.

Escape the content bar in a simple table

Pandoc documents pipes as column boundaries and backslash escapes for literal punctuation outside code. For an ordinary text cell, this example uses a backslash before the bar inside the value:

| Key | Value |
| --- | --- |
| choice | A\|B |

Keep the structural separators unchanged. The intended output has two columns and a value of A|B in the second cell, without the escape backslash.

We converted this exact sample using FileMyLove's bundled Pandoc worker and inspected the DOCX: the value remained A|B in one cell. This is a verified plain-text-cell example, not a promise for every Markdown editor or complex inline-code expression.

Avoid a global replacement

Replacing every bar with an escaped bar would also change the column separators. Our recommendation is to inspect only cells whose actual content contains a vertical bar, such as alternatives or technical notation.

If the value contains backticks or backslashes as data too, test that specific text separately. Pandoc's ordinary backslash-escape rules do not apply in verbatim code contexts. For complicated examples, consider placing the exact text in a code block outside the table.

Check the converted value

  1. Keep the original Markdown file.
  2. Test a short table containing the difficult value.
  3. Convert it with Markdown to Word.
  4. Compare the header count and the cells in the affected row.
  5. Copy the value from Word into a plain-text editor and check that it contains exactly the intended punctuation.

The converter does not infer whether a bar was meant as a separator or data. Correct the source syntax when the result is wrong; do not merely move the displayed text until it looks aligned.

For the full table structure and width checks, see Markdown table columns in Word. For longer literal examples, see preserving Markdown symbols.