markdown: Render checkboxes in markdown table cells#50595
Merged
Veykril merged 1 commit intozed-industries:mainfrom Mar 19, 2026
Merged
markdown: Render checkboxes in markdown table cells#50595Veykril merged 1 commit intozed-industries:mainfrom
Veykril merged 1 commit intozed-industries:mainfrom
Conversation
Contributor
Author
|
@Veykril does this also need rebasing? Happy to do it if needed, and do a new commit. saves you from needing to |
Member
|
yea |
Detect `[x]`, `[X]`, and `[ ]` patterns in table cells and render them as checkbox widgets instead of raw text. Both the `markdown` crate (agent panel) and `markdown_preview` crate (file preview) are covered. pulldown-cmark splits these into three separate Text events per the GFM spec, so detection operates on accumulated cell text rather than individual parser events. Fixes zed-industries#50045 Liam
auto-merge was automatically disabled
March 19, 2026 14:57
Head branch was pushed to by a user without write access
06dc3b3 to
5637c9b
Compare
Contributor
Author
|
@Veykril done |
AmaanBilwar
pushed a commit
to AmaanBilwar/zed
that referenced
this pull request
Mar 20, 2026
…0595) Render `[x]` and `[ ]` as checkbox widgets when they appear as the sole content of a markdown table cell. Previously these were displayed as raw text. List-item checkboxes were already rendered correctly; this extends the same treatment to table cells. Fixes zed-industries#50045. ## What this does - Table cells containing only `[x]`, `[X]`, or `[ ]` now render as visual checkboxes instead of plain text - Both markdown rendering paths are covered: the `markdown` crate (agent panel, chat) and the `markdown_preview` crate (file preview) - Checkboxes are display-only, matching the existing list-item checkbox behavior ## How it works pulldown-cmark splits `[x]` in table cells into three separate `Text` events (`[`, `x`, `]`) rather than emitting a `TaskListMarker` event (which only fires for list items per the GFM spec). The fix operates at each crate's natural interception point: - **`markdown` crate**: After all text events for a table cell have been buffered, `replace_pending_checkbox()` checks the accumulated text before the cell div is finalized. If it matches the checkbox pattern, the pending text is replaced with a `Checkbox` widget. - **`markdown_preview` crate**: In `render_markdown_text()`, text chunks whose trimmed content matches the checkbox pattern are rendered as `MarkdownCheckbox` widgets instead of `InteractiveText`. ## Scope Three files, purely additive: - `crates/markdown/src/markdown.rs` — `replace_pending_checkbox()` on builder, called at `TableCell` end - `crates/markdown_preview/src/markdown_renderer.rs` — checkbox detection in `render_markdown_text()` - `crates/markdown_preview/src/markdown_parser.rs` — test only No changes to parser data models, GPUI, or any shared infrastructure. ## What's not in scope - **HTML `<input type="checkbox">`** — pulldown-cmark strips these as raw HTML. Supporting them requires HTML tag parsing, which is a separate concern. - **Interactive (click-to-toggle) checkboxes in tables** — table checkboxes are display-only. List-item checkboxes in Zed support Cmd+click toggling, but extending that to table cells would require tracking source ranges across the split parser events, which is a separate enhancement. ## Follow-up Table checkbox interactivity (Cmd+click toggle) is straightforward to add as a follow-up — the source ranges are already available in `markdown_preview`, and the `markdown` crate would need minor callback plumbing. ## Screenshots **Markdown checkbox before** <img width="1603" height="863" alt="md-checkbox-before-1" src="https://github.com/user-attachments/assets/8539d79d-c74f-4d14-a3e5-525e4d0083aa" /> <img width="1599" height="892" alt="md-checkbox-before-2" src="https://github.com/user-attachments/assets/7badfab1-651f-4fab-8879-deb109c56670" /> **Markdown checkbox after** <img width="1832" height="889" alt="md-checkbox-after-1" src="https://github.com/user-attachments/assets/463b6334-9f50-41c0-ab7e-24d238244873" /> <img width="1795" height="886" alt="md-checkbox-after-2" src="https://github.com/user-attachments/assets/57d3d9de-1d23-42ba-bc0a-5aa0c699b13d" /> ## Test plan **Unit tests** (2 new): - `test_table_with_checkboxes` (markdown_preview) — parser delivers `[x]`/`[ ]` text into table cell structures - `test_table_checkbox_detection` (markdown) — parser events accumulate checkbox text in table cells, confirming `replace_pending_checkbox` detection logic **Automated**: - [x] `cargo test -p markdown` — 27 tests pass (26 existing + 1 new) - [x] `cargo test -p markdown_preview` — 61 tests pass (60 existing + 1 new) **Manual** (verified against `test-checkbox-table.md`): - [x] Basic `[x]`/`[ ]` in a status column - [x] Checkbox-only column alongside text - [x] Multiple checkbox columns in one table - [x] Left, center, and right column alignments - [x] Uppercase `[X]` variant - [x] Leading/trailing whitespace in cell - [x] Checkboxes alongside other inline elements (links, bold text) - [x] Single-column and minimal two-column tables - [x] Normal table text unaffected by detection - [x] List checkboxes still render correctly (regression) - [x] Agent panel: asked agent to output table with checkbox columns Release Notes: - Fixed `[x]` and `[ ]` checkboxes not rendering in markdown table cells (zed-industries#50045)
toshmukhamedov
pushed a commit
to toshmukhamedov/zed
that referenced
this pull request
Mar 20, 2026
…0595) Render `[x]` and `[ ]` as checkbox widgets when they appear as the sole content of a markdown table cell. Previously these were displayed as raw text. List-item checkboxes were already rendered correctly; this extends the same treatment to table cells. Fixes zed-industries#50045. ## What this does - Table cells containing only `[x]`, `[X]`, or `[ ]` now render as visual checkboxes instead of plain text - Both markdown rendering paths are covered: the `markdown` crate (agent panel, chat) and the `markdown_preview` crate (file preview) - Checkboxes are display-only, matching the existing list-item checkbox behavior ## How it works pulldown-cmark splits `[x]` in table cells into three separate `Text` events (`[`, `x`, `]`) rather than emitting a `TaskListMarker` event (which only fires for list items per the GFM spec). The fix operates at each crate's natural interception point: - **`markdown` crate**: After all text events for a table cell have been buffered, `replace_pending_checkbox()` checks the accumulated text before the cell div is finalized. If it matches the checkbox pattern, the pending text is replaced with a `Checkbox` widget. - **`markdown_preview` crate**: In `render_markdown_text()`, text chunks whose trimmed content matches the checkbox pattern are rendered as `MarkdownCheckbox` widgets instead of `InteractiveText`. ## Scope Three files, purely additive: - `crates/markdown/src/markdown.rs` — `replace_pending_checkbox()` on builder, called at `TableCell` end - `crates/markdown_preview/src/markdown_renderer.rs` — checkbox detection in `render_markdown_text()` - `crates/markdown_preview/src/markdown_parser.rs` — test only No changes to parser data models, GPUI, or any shared infrastructure. ## What's not in scope - **HTML `<input type="checkbox">`** — pulldown-cmark strips these as raw HTML. Supporting them requires HTML tag parsing, which is a separate concern. - **Interactive (click-to-toggle) checkboxes in tables** — table checkboxes are display-only. List-item checkboxes in Zed support Cmd+click toggling, but extending that to table cells would require tracking source ranges across the split parser events, which is a separate enhancement. ## Follow-up Table checkbox interactivity (Cmd+click toggle) is straightforward to add as a follow-up — the source ranges are already available in `markdown_preview`, and the `markdown` crate would need minor callback plumbing. ## Screenshots **Markdown checkbox before** <img width="1603" height="863" alt="md-checkbox-before-1" src="https://github.com/user-attachments/assets/8539d79d-c74f-4d14-a3e5-525e4d0083aa" /> <img width="1599" height="892" alt="md-checkbox-before-2" src="https://github.com/user-attachments/assets/7badfab1-651f-4fab-8879-deb109c56670" /> **Markdown checkbox after** <img width="1832" height="889" alt="md-checkbox-after-1" src="https://github.com/user-attachments/assets/463b6334-9f50-41c0-ab7e-24d238244873" /> <img width="1795" height="886" alt="md-checkbox-after-2" src="https://github.com/user-attachments/assets/57d3d9de-1d23-42ba-bc0a-5aa0c699b13d" /> ## Test plan **Unit tests** (2 new): - `test_table_with_checkboxes` (markdown_preview) — parser delivers `[x]`/`[ ]` text into table cell structures - `test_table_checkbox_detection` (markdown) — parser events accumulate checkbox text in table cells, confirming `replace_pending_checkbox` detection logic **Automated**: - [x] `cargo test -p markdown` — 27 tests pass (26 existing + 1 new) - [x] `cargo test -p markdown_preview` — 61 tests pass (60 existing + 1 new) **Manual** (verified against `test-checkbox-table.md`): - [x] Basic `[x]`/`[ ]` in a status column - [x] Checkbox-only column alongside text - [x] Multiple checkbox columns in one table - [x] Left, center, and right column alignments - [x] Uppercase `[X]` variant - [x] Leading/trailing whitespace in cell - [x] Checkboxes alongside other inline elements (links, bold text) - [x] Single-column and minimal two-column tables - [x] Normal table text unaffected by detection - [x] List checkboxes still render correctly (regression) - [x] Agent panel: asked agent to output table with checkbox columns Release Notes: - Fixed `[x]` and `[ ]` checkboxes not rendering in markdown table cells (zed-industries#50045)
AmaanBilwar
pushed a commit
to AmaanBilwar/zed
that referenced
this pull request
Mar 23, 2026
…0595) Render `[x]` and `[ ]` as checkbox widgets when they appear as the sole content of a markdown table cell. Previously these were displayed as raw text. List-item checkboxes were already rendered correctly; this extends the same treatment to table cells. Fixes zed-industries#50045. ## What this does - Table cells containing only `[x]`, `[X]`, or `[ ]` now render as visual checkboxes instead of plain text - Both markdown rendering paths are covered: the `markdown` crate (agent panel, chat) and the `markdown_preview` crate (file preview) - Checkboxes are display-only, matching the existing list-item checkbox behavior ## How it works pulldown-cmark splits `[x]` in table cells into three separate `Text` events (`[`, `x`, `]`) rather than emitting a `TaskListMarker` event (which only fires for list items per the GFM spec). The fix operates at each crate's natural interception point: - **`markdown` crate**: After all text events for a table cell have been buffered, `replace_pending_checkbox()` checks the accumulated text before the cell div is finalized. If it matches the checkbox pattern, the pending text is replaced with a `Checkbox` widget. - **`markdown_preview` crate**: In `render_markdown_text()`, text chunks whose trimmed content matches the checkbox pattern are rendered as `MarkdownCheckbox` widgets instead of `InteractiveText`. ## Scope Three files, purely additive: - `crates/markdown/src/markdown.rs` — `replace_pending_checkbox()` on builder, called at `TableCell` end - `crates/markdown_preview/src/markdown_renderer.rs` — checkbox detection in `render_markdown_text()` - `crates/markdown_preview/src/markdown_parser.rs` — test only No changes to parser data models, GPUI, or any shared infrastructure. ## What's not in scope - **HTML `<input type="checkbox">`** — pulldown-cmark strips these as raw HTML. Supporting them requires HTML tag parsing, which is a separate concern. - **Interactive (click-to-toggle) checkboxes in tables** — table checkboxes are display-only. List-item checkboxes in Zed support Cmd+click toggling, but extending that to table cells would require tracking source ranges across the split parser events, which is a separate enhancement. ## Follow-up Table checkbox interactivity (Cmd+click toggle) is straightforward to add as a follow-up — the source ranges are already available in `markdown_preview`, and the `markdown` crate would need minor callback plumbing. ## Screenshots **Markdown checkbox before** <img width="1603" height="863" alt="md-checkbox-before-1" src="https://github.com/user-attachments/assets/8539d79d-c74f-4d14-a3e5-525e4d0083aa" /> <img width="1599" height="892" alt="md-checkbox-before-2" src="https://github.com/user-attachments/assets/7badfab1-651f-4fab-8879-deb109c56670" /> **Markdown checkbox after** <img width="1832" height="889" alt="md-checkbox-after-1" src="https://github.com/user-attachments/assets/463b6334-9f50-41c0-ab7e-24d238244873" /> <img width="1795" height="886" alt="md-checkbox-after-2" src="https://github.com/user-attachments/assets/57d3d9de-1d23-42ba-bc0a-5aa0c699b13d" /> ## Test plan **Unit tests** (2 new): - `test_table_with_checkboxes` (markdown_preview) — parser delivers `[x]`/`[ ]` text into table cell structures - `test_table_checkbox_detection` (markdown) — parser events accumulate checkbox text in table cells, confirming `replace_pending_checkbox` detection logic **Automated**: - [x] `cargo test -p markdown` — 27 tests pass (26 existing + 1 new) - [x] `cargo test -p markdown_preview` — 61 tests pass (60 existing + 1 new) **Manual** (verified against `test-checkbox-table.md`): - [x] Basic `[x]`/`[ ]` in a status column - [x] Checkbox-only column alongside text - [x] Multiple checkbox columns in one table - [x] Left, center, and right column alignments - [x] Uppercase `[X]` variant - [x] Leading/trailing whitespace in cell - [x] Checkboxes alongside other inline elements (links, bold text) - [x] Single-column and minimal two-column tables - [x] Normal table text unaffected by detection - [x] List checkboxes still render correctly (regression) - [x] Agent panel: asked agent to output table with checkbox columns Release Notes: - Fixed `[x]` and `[ ]` checkboxes not rendering in markdown table cells (zed-industries#50045)
Contributor
|
Any issues if the checkboxes were clickable? #53587 |
11 tasks
Contributor
Author
iam-liam
added a commit
to iam-liam/zed
that referenced
this pull request
Apr 24, 2026
Extend the table cell checkbox rendering added in zed-industries#50595 so that checkboxes participate in the existing `on_checkbox_toggle` pipeline. When a consumer supplies a toggle callback (for example `markdown_preview`, which rewrites the source file), clicking a table cell checkbox now toggles `[x]` ↔ `[ ]` in the underlying source — matching the behavior of list-item checkboxes. The marker's source range is reconstructed from the per-chunk source mappings on the pending line, since pulldown-cmark splits `[x]` in table cells into three separate `Text` events.
cppcoffee
pushed a commit
to cppcoffee/zed
that referenced
this pull request
Apr 24, 2026
Closes zed-industries#53587 Follow-up to zed-industries#50595. [zed-industries#50595](zed-industries#50595) added display-only checkboxes when `[x]` / `[X]` / `[ ]` appears as the sole content of a markdown table cell. That PR called out interactivity as a later step — this PR delivers it. https://github.com/user-attachments/assets/c666ee4c-7e31-4450-ab33-c07c82949818 ## What this does When a consumer of `MarkdownElement` supplies an `on_checkbox_toggle` callback, table-cell checkboxes now invoke it on click with the source range of the `[x]` / `[ ]` marker and the new checked state. This mirrors the existing list-item checkbox path. For markdown preview (`markdown_preview_view.rs`) the callback is already wired to edit the source buffer, so clicking a checkbox in a previewed `.md` file now flips `[x]` to `[ ]` and back in the file, the same as it already did for list checkboxes. ## How it works `replace_pending_checkbox` previously took the cell's outer source range and always built a visualization-only checkbox. It now takes the optional toggle callback instead, and reconstructs the marker's exact source range from `pending_line.source_mappings` — pulldown-cmark emits `[x]` in a table cell as three separate `Text` events, so the per-chunk mappings are needed to recover the 3-character range to rewrite. If a callback was supplied, the checkbox attaches an `on_click` that invokes it with that range and `!checked`; otherwise it falls back to the prior visualization-only rendering. Two free helpers (`source_range_for_rendered` / `source_index_for_rendered`) were extracted so the mapping logic is unit-testable. ## Scope One file: `crates/markdown/src/markdown.rs`. No changes to `markdown_preview` — since zed-industries#52008 it renders through the shared `MarkdownElement`, so its existing `on_checkbox_toggle` wiring picks up table checkboxes for free. ## Relation to zed-industries#53587 [zed-industries#53587](zed-industries#53587) reports that markdown checkboxes in the **agent panel** can't be clicked. This PR is a necessary piece of that fix — without it, even if the agent panel wired `on_checkbox_toggle`, its table checkboxes would stay inert. It does not fully close zed-industries#53587 on its own: the agent panel's `MarkdownElement` instances in `conversation_view.rs` / `thread_view.rs` don't currently wire `on_checkbox_toggle`, and wiring it there requires deciding how clicks should mutate the in-memory agent response (no source file to edit into). That's a follow-up. ## Test plan **Unit tests** (2 new, both in `crates/markdown/src/markdown.rs`): - `test_table_checkbox_marker_source_range` — walks parser events for a table with checkboxes, replays what the builder accumulates, and asserts the reconstructed source range slices to exactly `[x]` / `[ ]` in the original markdown (including a padded-whitespace case). - `test_source_range_for_rendered_handles_split_chunks` — pins the mapping helper against the three-chunk layout pulldown-cmark produces. **Automated**: - [x] `cargo test -p markdown` — 46 tests pass (44 existing + 2 new) - [x] `cargo test -p markdown_preview` — 3 tests pass - [x] `./script/clippy -p markdown` — clean **Manual** (against a preview of a markdown file with checkbox tables): - [x] Click a checked `[x]` table cell — it becomes `[ ]` in the source and rerenders as unchecked - [x] Click an unchecked `[ ]` — becomes `[x]` - [x] Uppercase `[X]` toggles on click (replacement writes `[x]` / `[ ]`, matching the list-item behaviour) - [x] Padded-whitespace cells still target just the three marker characters - [x] Multiple checkbox columns in one table all independently clickable - [x] Alignment variants (left/center/right) behave the same - [x] Non-checkbox table text unaffected - [x] List-item checkboxes continue to work (regression) Release Notes: - Made table-cell markdown checkboxes clickable in markdown preview, matching list-item checkbox behavior Co-authored-by: Lukas Wirth <lukas@zed.dev>
piper-of-dawn
pushed a commit
to piper-of-dawn/zed
that referenced
this pull request
Apr 25, 2026
…0595) Render `[x]` and `[ ]` as checkbox widgets when they appear as the sole content of a markdown table cell. Previously these were displayed as raw text. List-item checkboxes were already rendered correctly; this extends the same treatment to table cells. Fixes zed-industries#50045. ## What this does - Table cells containing only `[x]`, `[X]`, or `[ ]` now render as visual checkboxes instead of plain text - Both markdown rendering paths are covered: the `markdown` crate (agent panel, chat) and the `markdown_preview` crate (file preview) - Checkboxes are display-only, matching the existing list-item checkbox behavior ## How it works pulldown-cmark splits `[x]` in table cells into three separate `Text` events (`[`, `x`, `]`) rather than emitting a `TaskListMarker` event (which only fires for list items per the GFM spec). The fix operates at each crate's natural interception point: - **`markdown` crate**: After all text events for a table cell have been buffered, `replace_pending_checkbox()` checks the accumulated text before the cell div is finalized. If it matches the checkbox pattern, the pending text is replaced with a `Checkbox` widget. - **`markdown_preview` crate**: In `render_markdown_text()`, text chunks whose trimmed content matches the checkbox pattern are rendered as `MarkdownCheckbox` widgets instead of `InteractiveText`. ## Scope Three files, purely additive: - `crates/markdown/src/markdown.rs` — `replace_pending_checkbox()` on builder, called at `TableCell` end - `crates/markdown_preview/src/markdown_renderer.rs` — checkbox detection in `render_markdown_text()` - `crates/markdown_preview/src/markdown_parser.rs` — test only No changes to parser data models, GPUI, or any shared infrastructure. ## What's not in scope - **HTML `<input type="checkbox">`** — pulldown-cmark strips these as raw HTML. Supporting them requires HTML tag parsing, which is a separate concern. - **Interactive (click-to-toggle) checkboxes in tables** — table checkboxes are display-only. List-item checkboxes in Zed support Cmd+click toggling, but extending that to table cells would require tracking source ranges across the split parser events, which is a separate enhancement. ## Follow-up Table checkbox interactivity (Cmd+click toggle) is straightforward to add as a follow-up — the source ranges are already available in `markdown_preview`, and the `markdown` crate would need minor callback plumbing. ## Screenshots **Markdown checkbox before** <img width="1603" height="863" alt="md-checkbox-before-1" src="https://github.com/user-attachments/assets/8539d79d-c74f-4d14-a3e5-525e4d0083aa" /> <img width="1599" height="892" alt="md-checkbox-before-2" src="https://github.com/user-attachments/assets/7badfab1-651f-4fab-8879-deb109c56670" /> **Markdown checkbox after** <img width="1832" height="889" alt="md-checkbox-after-1" src="https://github.com/user-attachments/assets/463b6334-9f50-41c0-ab7e-24d238244873" /> <img width="1795" height="886" alt="md-checkbox-after-2" src="https://github.com/user-attachments/assets/57d3d9de-1d23-42ba-bc0a-5aa0c699b13d" /> ## Test plan **Unit tests** (2 new): - `test_table_with_checkboxes` (markdown_preview) — parser delivers `[x]`/`[ ]` text into table cell structures - `test_table_checkbox_detection` (markdown) — parser events accumulate checkbox text in table cells, confirming `replace_pending_checkbox` detection logic **Automated**: - [x] `cargo test -p markdown` — 27 tests pass (26 existing + 1 new) - [x] `cargo test -p markdown_preview` — 61 tests pass (60 existing + 1 new) **Manual** (verified against `test-checkbox-table.md`): - [x] Basic `[x]`/`[ ]` in a status column - [x] Checkbox-only column alongside text - [x] Multiple checkbox columns in one table - [x] Left, center, and right column alignments - [x] Uppercase `[X]` variant - [x] Leading/trailing whitespace in cell - [x] Checkboxes alongside other inline elements (links, bold text) - [x] Single-column and minimal two-column tables - [x] Normal table text unaffected by detection - [x] List checkboxes still render correctly (regression) - [x] Agent panel: asked agent to output table with checkbox columns Release Notes: - Fixed `[x]` and `[ ]` checkboxes not rendering in markdown table cells (zed-industries#50045)
ebaah46
pushed a commit
to ebaah46/zed
that referenced
this pull request
May 6, 2026
Closes zed-industries#53587 Follow-up to zed-industries#50595. [zed-industries#50595](zed-industries#50595) added display-only checkboxes when `[x]` / `[X]` / `[ ]` appears as the sole content of a markdown table cell. That PR called out interactivity as a later step — this PR delivers it. https://github.com/user-attachments/assets/c666ee4c-7e31-4450-ab33-c07c82949818 ## What this does When a consumer of `MarkdownElement` supplies an `on_checkbox_toggle` callback, table-cell checkboxes now invoke it on click with the source range of the `[x]` / `[ ]` marker and the new checked state. This mirrors the existing list-item checkbox path. For markdown preview (`markdown_preview_view.rs`) the callback is already wired to edit the source buffer, so clicking a checkbox in a previewed `.md` file now flips `[x]` to `[ ]` and back in the file, the same as it already did for list checkboxes. ## How it works `replace_pending_checkbox` previously took the cell's outer source range and always built a visualization-only checkbox. It now takes the optional toggle callback instead, and reconstructs the marker's exact source range from `pending_line.source_mappings` — pulldown-cmark emits `[x]` in a table cell as three separate `Text` events, so the per-chunk mappings are needed to recover the 3-character range to rewrite. If a callback was supplied, the checkbox attaches an `on_click` that invokes it with that range and `!checked`; otherwise it falls back to the prior visualization-only rendering. Two free helpers (`source_range_for_rendered` / `source_index_for_rendered`) were extracted so the mapping logic is unit-testable. ## Scope One file: `crates/markdown/src/markdown.rs`. No changes to `markdown_preview` — since zed-industries#52008 it renders through the shared `MarkdownElement`, so its existing `on_checkbox_toggle` wiring picks up table checkboxes for free. ## Relation to zed-industries#53587 [zed-industries#53587](zed-industries#53587) reports that markdown checkboxes in the **agent panel** can't be clicked. This PR is a necessary piece of that fix — without it, even if the agent panel wired `on_checkbox_toggle`, its table checkboxes would stay inert. It does not fully close zed-industries#53587 on its own: the agent panel's `MarkdownElement` instances in `conversation_view.rs` / `thread_view.rs` don't currently wire `on_checkbox_toggle`, and wiring it there requires deciding how clicks should mutate the in-memory agent response (no source file to edit into). That's a follow-up. ## Test plan **Unit tests** (2 new, both in `crates/markdown/src/markdown.rs`): - `test_table_checkbox_marker_source_range` — walks parser events for a table with checkboxes, replays what the builder accumulates, and asserts the reconstructed source range slices to exactly `[x]` / `[ ]` in the original markdown (including a padded-whitespace case). - `test_source_range_for_rendered_handles_split_chunks` — pins the mapping helper against the three-chunk layout pulldown-cmark produces. **Automated**: - [x] `cargo test -p markdown` — 46 tests pass (44 existing + 2 new) - [x] `cargo test -p markdown_preview` — 3 tests pass - [x] `./script/clippy -p markdown` — clean **Manual** (against a preview of a markdown file with checkbox tables): - [x] Click a checked `[x]` table cell — it becomes `[ ]` in the source and rerenders as unchecked - [x] Click an unchecked `[ ]` — becomes `[x]` - [x] Uppercase `[X]` toggles on click (replacement writes `[x]` / `[ ]`, matching the list-item behaviour) - [x] Padded-whitespace cells still target just the three marker characters - [x] Multiple checkbox columns in one table all independently clickable - [x] Alignment variants (left/center/right) behave the same - [x] Non-checkbox table text unaffected - [x] List-item checkboxes continue to work (regression) Release Notes: - Made table-cell markdown checkboxes clickable in markdown preview, matching list-item checkbox behavior Co-authored-by: Lukas Wirth <lukas@zed.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Render
[x]and[ ]as checkbox widgets when they appear as the sole content of a markdown table cell. Previously these were displayed as raw text. List-item checkboxes were already rendered correctly; this extends the same treatment to table cells.Fixes #50045.
What this does
[x],[X], or[ ]now render as visual checkboxes instead of plain textmarkdowncrate (agent panel, chat) and themarkdown_previewcrate (file preview)How it works
pulldown-cmark splits
[x]in table cells into three separateTextevents ([,x,]) rather than emitting aTaskListMarkerevent (which only fires for list items per the GFM spec). The fix operates at each crate's natural interception point:markdowncrate: After all text events for a table cell have been buffered,replace_pending_checkbox()checks the accumulated text before the cell div is finalized. If it matches the checkbox pattern, the pending text is replaced with aCheckboxwidget.markdown_previewcrate: Inrender_markdown_text(), text chunks whose trimmed content matches the checkbox pattern are rendered asMarkdownCheckboxwidgets instead ofInteractiveText.Scope
Three files, purely additive:
crates/markdown/src/markdown.rs—replace_pending_checkbox()on builder, called atTableCellendcrates/markdown_preview/src/markdown_renderer.rs— checkbox detection inrender_markdown_text()crates/markdown_preview/src/markdown_parser.rs— test onlyNo changes to parser data models, GPUI, or any shared infrastructure.
What's not in scope
<input type="checkbox">— pulldown-cmark strips these as raw HTML. Supporting them requires HTML tag parsing, which is a separate concern.Follow-up
Table checkbox interactivity (Cmd+click toggle) is straightforward to add as a follow-up — the source ranges are already available in
markdown_preview, and themarkdowncrate would need minor callback plumbing.Screenshots
Markdown checkbox before
Markdown checkbox after
Test plan
Unit tests (2 new):
test_table_with_checkboxes(markdown_preview) — parser delivers[x]/[ ]text into table cell structurestest_table_checkbox_detection(markdown) — parser events accumulate checkbox text in table cells, confirmingreplace_pending_checkboxdetection logicAutomated:
cargo test -p markdown— 27 tests pass (26 existing + 1 new)cargo test -p markdown_preview— 61 tests pass (60 existing + 1 new)Manual (verified against
test-checkbox-table.md):[x]/[ ]in a status column[X]variantRelease Notes:
[x]and[ ]checkboxes not rendering in markdown table cells (Checkboxes aren't rendered in tables in markdown preview within agent panel #50045)