Skip to content

fix(tui): protect pipe characters inside inline code in markdown tables#5812

Closed
aliou wants to merge 1 commit into
earendil-works:mainfrom
aliou:fix/markdown-pipe-parsing-bug
Closed

fix(tui): protect pipe characters inside inline code in markdown tables#5812
aliou wants to merge 1 commit into
earendil-works:mainfrom
aliou:fix/markdown-pipe-parsing-bug

Conversation

@aliou

@aliou aliou commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Hello!

Noticed this bug: when rendering a table that has in one of its cell a | inside of backsticks, marked will use as a column delimitor and split on it, discarding the content after it.

To handle it, this uses the existing custom tokenizer and overrides how table should be rendered, customizing the column split.

Session: https://pi.dev/session/#fbe66e539f15604016fa459a55a89ed7

One caveat: the verison of marked is a couple of majors late and in the latest version, the API around tokenizer changes for the existing del overrides; the rest of the API is the same (see other tree in the session for the check).

Let me know if you need/want more other changes!

Before

Screenshot 2026-06-16 at 03 56 48 PM@2x

After

Screenshot 2026-06-16 at 03 57 08 PM@2x


Summary by Kimi K2.7 Code:

What changed

  • packages/tui/src/components/markdown.ts: Replaced StrictStrikethroughTokenizer with MarkdownTokenizer. It keeps the existing strict strikethrough del override and adds a table override.
  • The new table method uses splitCellsRespectingCodeSpans, which splits table rows on | while treating everything inside backtick code spans as literal text. It still honors \| as an escaped pipe.

Why

marked tokenizes table rows before resolving inline code spans. A cell like `TFile | null` was therefore split at the pipe, and because marked truncates rows to the header column count, the trailing | null was silently dropped.

Verification

  • npm run check passes.
  • node --test test/*.test.ts in packages/tui passes (682 tests), including the new regression test in packages/tui/test/markdown.test.ts.
  • ./test.sh from root currently fails on unrelated packages/coding-agent tests (session-id-readonly.test.ts, footer-data-provider.test.ts), not on this change.

@aliou aliou force-pushed the fix/markdown-pipe-parsing-bug branch from f94364f to 3878f6f Compare June 16, 2026 14:12
@mitsuhiko

Copy link
Copy Markdown
Member

I just upgraded marked instead which appears to solve this problem too.

@mitsuhiko mitsuhiko closed this Jun 16, 2026
@aliou aliou deleted the fix/markdown-pipe-parsing-bug branch June 16, 2026 16:30
@aliou

aliou commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Doesn't seem fixed on my end on latest pi:
Screenshot 2026-06-17 at 05 40 31 AM@2x

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.

2 participants