Skip to content

fix(markdown): escape pipes in code spans inside table cells - #110

Merged
tomsideguide merged 5 commits into
mainfrom
fix/table-cell-code-span-pipes
Aug 19, 2026
Merged

fix(markdown): escape pipes in code spans inside table cells#110
tomsideguide merged 5 commits into
mainfrom
fix/table-cell-code-span-pipes

Conversation

@tomsideguide

@tomsideguide tomsideguide commented Aug 19, 2026

Copy link
Copy Markdown
Member

A row is split into cells before any inline is parsed, so a pipe is syntax inside a code span too. Plain text, styled text and URLs already escaped it in a cell; code spans did not, because push_code_span was the one emitter that never received the context it was rendering into.

Both cell code paths route through it, the inline code run and a <pre> block in a cell, so passing the context fixes both.

Before, on a two-column table:

| `a | b` | bitwise or |

The delimiter row declares two columns and the body row emits three, so a GFM renderer drops bitwise or and tears the code span in half. After:

| `a \| b` | bitwise or |

Closes #84


Summary by cubic

Escapes pipes in Markdown code spans inside table cells so they no longer split columns. Previously, a pipe in a cell code span acted as a delimiter; now it renders as |, and an existing | renders as \| to preserve the escape. Code outside tables is unchanged.

  • Pass InlineContext into push_code_span and escape only for InlineContext::TableCell.
  • Route both inline code and cell <pre> code through push_code_span; add tests for "a | b" and pre-escaped "a | b".
  • Move and rename the escaper to escape.rs as escape_cell_code_span; restore the backtick_fence doc comment.

Written for commit 85d3606. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread src/render/markdown/inline.rs Outdated
@tomsideguide
tomsideguide merged commit aa6ab89 into main Aug 19, 2026
5 checks passed
@tomsideguide
tomsideguide deleted the fix/table-cell-code-span-pipes branch August 19, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

markdown: a pipe inside a code span in a table cell is not escaped, splitting the GFM row and dropping later columns

1 participant