Skip to content

markdown_preview: Refactor to use shared markdown crate#52008

Merged
smitbarmase merged 12 commits intomainfrom
markdown-preview-refactor
Mar 26, 2026
Merged

markdown_preview: Refactor to use shared markdown crate#52008
smitbarmase merged 12 commits intomainfrom
markdown-preview-refactor

Conversation

@smitbarmase
Copy link
Copy Markdown
Member

@smitbarmase smitbarmase commented Mar 20, 2026

We now use the parser and renderer from the markdown crate for Markdown Preview, instead of maintaining two separate code paths.

How it works:

markdown_preview_view.rs is now a consumer of MarkdownElement. It acts as a thin wrapper, handling things like resolving URL clicks and image URLs, which can vary between consumers. It also handles syncing the editor selection with the active block in the preview. The APIs for this are provided by MarkdownElement.

All the heavy lifting like parsing HTML, rendering block markers on hover, handling the active block, etc. is done by MarkdownElement. Everything is opt-in. For example, markdown in the Agent Panel can choose not to enable block marker rendering or HTML parsing, while Markdown Preview opts into those features.

Final outcome:

For Markdown Preview View:

  • Added:

    • Selection support in the preview
  • Stays:

    • Syncing between editor and preview
    • Autoscroll
    • Hover and active block markers
    • Checkbox toggling
    • Image rendering
    • Mermaid rendering

For the markdown crate:

  • No changes for existing consumers like the Agent Panel
  • Consumers can now opt into:
    • HTML rendering
    • Block marker rendering
    • Click event handling
    • Custom image resolvers
    • Mermaid rendering

Release Notes:

  • N/A

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 20, 2026
@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Mar 20, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator bot requested review from a team, Anthony-Eid and osiewicz and removed request for a team March 20, 2026 11:56
mac9sb added a commit to mac9sb/zed that referenced this pull request Mar 23, 2026
Merge the markdown preview refactor (PR zed-industries#52008) which replaces the custom
markdown_elements/markdown_parser/markdown_renderer modules with the shared
markdown crate. Port the navigation features (link click behavior settings,
back/forward nav history, navigate-to-markdown-file) to work with the new
MarkdownElement API.
@smitbarmase smitbarmase force-pushed the markdown-preview-refactor branch from 8752ef7 to 774f03a Compare March 24, 2026 08:31
@github-actions
Copy link
Copy Markdown

📏 PR Size: 8278 lines changed (Size XL)

Please note: this PR exceeds the 400 LOC soft limit.

  • Consider splitting into separate PRs if the changes are separable
  • Ensure the PR description includes a guided tour in the "How to Review" section so reviewers know where to start

@smitbarmase smitbarmase force-pushed the markdown-preview-refactor branch from 1ab80cc to d423928 Compare March 24, 2026 22:41
@smitbarmase smitbarmase force-pushed the markdown-preview-refactor branch from d423928 to 6798ec4 Compare March 26, 2026 06:03
@smitbarmase smitbarmase merged commit 9efe3c5 into main Mar 26, 2026
31 checks passed
@smitbarmase smitbarmase deleted the markdown-preview-refactor branch March 26, 2026 06:57
@balcsida
Copy link
Copy Markdown

Closes #16727

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:preview/markdown cla-signed The user has signed the Contributor License Agreement large-pr staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants