Skip to content

Fix pipe after backslash in code in a table cell splitting the row - #12

Open
MFA-G wants to merge 1 commit into
syntax-tree:mainfrom
MFA-G:fix/inline-code-backslash-pipe
Open

MFA-G wants to merge 1 commit into
syntax-tree:mainfrom
MFA-G:fix/inline-code-backslash-pipe

Conversation

@MFA-G

@MFA-G MFA-G commented Oct 20, 2026 •

Copy link
Copy Markdown

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything or linked relevant results below
  • I made sure the docs are up to date
  • I included tests (or that’s not needed)

Description of changes

Closes GH-11.

inlineCodeWithTable puts a backslash before every | in code in a cell. When the pipe already has a backslash in front of it, that makes \\|. The first backslash then escapes the second, the pipe acts as a cell delimiter, and the row reads back with an extra cell.

This changes the handler to count the backslashes before each pipe and only add one when the count is even, so the pipe always ends up after an odd run and stays in the cell:

code value before after
a|b `a\\|b` (row splits) `a|b`
a\|b `a\\|b` unchanged
| `\\|` (row splits) `|`

GFM has no way to write a backslash right before a pipe in code in a cell (\| reads as |, and from-markdown keeps \\ as \\). So a value with an odd number of backslashes before a pipe loses one backslash, as the issue suggests: a\|b reads back as a|b. The row structure is kept, which matters more. Values with an even count, like a\\|b, round-trip exactly.

Tests: two new cases. One checks the serialized output, the other round-trips a table through toMarkdown and fromMarkdown for several backslash/pipe combinations and checks the cell count and code value. Both fail without the change. npm test (build, type coverage, format, 100% coverage) passes.

I used an AI coding assistant to help write this change. I reviewed and tested the result myself.

@github-actions github-actions Bot added the 👋 phase/new Post is being triaged automatically label Oct 20, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤞 phase/open Post is being triaged manually

Development

Successfully merging this pull request may close these issues.

Inline code with \| in a table cell splits the row

1 participant