Skip to content

Keep inline code pipes inside markdown table cells#57744

Merged
smitbarmase merged 7 commits into
zed-industries:mainfrom
AnkanMisra:fix/57683-markdown-inline-code-pipes
Jun 26, 2026
Merged

Keep inline code pipes inside markdown table cells#57744
smitbarmase merged 7 commits into
zed-industries:mainfrom
AnkanMisra:fix/57683-markdown-inline-code-pipes

Conversation

@AnkanMisra

@AnkanMisra AnkanMisra commented May 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes markdown table rendering when inline code spans contain pipe characters. Code such as `a|b` and `a||b` now stays in one table cell instead of being split into extra columns.

Why

Agent output and markdown previews can include regexes, shell snippets, and other code spans with | characters inside tables. Before this change, those pipes could be parsed as table delimiters even though they were part of inline code.

Changes

  • Masks raw pipes only inside matched inline code spans before pulldown-cmark parses tables.
  • Restores rendered code-span text from the original source range, including escaped table pipes.
  • Avoids masking unmatched backticks, fenced code blocks, indented code blocks, and invalid fence closers.
  • Adds parser and renderer coverage for raw pipes, escaped pipes, unmatched inline code, invalid fences, and code-span link callbacks.

Manual check: generated agent responses across multiple models render tables containing `a|b`, `(a|b)`, and `a||b` as single code-span cells rather than split columns.

Screenshots / Recordings

Before After
Before After

Self-Review Checklist

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #57683

Release Notes:

  • Fixed markdown table rendering for inline code spans that contain pipe characters.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 26, 2026
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label May 26, 2026
@AnkanMisra AnkanMisra force-pushed the fix/57683-markdown-inline-code-pipes branch from 8e42222 to fa7c53f Compare May 26, 2026 16:39
@AnkanMisra AnkanMisra changed the title Keep inline code pipes inside markdown table cells Keep inline code pipes inside markdown table cells May 26, 2026
@smitbarmase smitbarmase added the area:preview/markdown Feedback for Zed's Markdown preview label May 27, 2026
@smitbarmase smitbarmase self-assigned this May 27, 2026
@smitbarmase smitbarmase force-pushed the fix/57683-markdown-inline-code-pipes branch from fa7c53f to f5a40c1 Compare June 26, 2026 13:19

@smitbarmase smitbarmase left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks,@tomhoule and I decided to go forward with only the GFM approach, i.e., rendering \| as | in tables, but we don't think we need a more generic case for now, since it introduces a lot of complexity and maintainability burden. I think this should be enough for most cases. Thanks again.

@smitbarmase smitbarmase enabled auto-merge June 26, 2026 13:22
@smitbarmase smitbarmase added this pull request to the merge queue Jun 26, 2026
Merged via the queue into zed-industries:main with commit 90587dd Jun 26, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:preview/markdown Feedback for Zed's Markdown preview cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backslash-escaped pipes in inline code render literally inside Markdown tables

2 participants