Title: id(web): prosemirror_to_markdown keeps only the first text node of a code_block — multi-node blocks are truncated on save · Issue #882 · developing-today/code · GitHub
Open Graph Title: id(web): prosemirror_to_markdown keeps only the first text node of a code_block — multi-node blocks are truncated on save · Issue #882 · developing-today/code
X Title: id(web): prosemirror_to_markdown keeps only the first text node of a code_block — multi-node blocks are truncated on save · Issue #882 · developing-today/code
Description: Bug In pkgs/id/src/web/markdown.rs, json_to_ast's "code_block" arm reads only the first text child of the ProseMirror code block: // markdown.rs:~638-642 (main 45c817e0) let content = json["content"] .as_array() .and_then(|arr| arr.first...
Open Graph Description: Bug In pkgs/id/src/web/markdown.rs, json_to_ast's "code_block" arm reads only the first text child of the ProseMirror code block: // markdown.rs:~638-642 (main 45c817e0) let content = json["content...
X Description: Bug In pkgs/id/src/web/markdown.rs, json_to_ast's "code_block" arm reads only the first text child of the ProseMirror code block: // markdown.rs:~638-642 (main 45c817e0) let content =...
Opengraph URL: https://github.com/developing-today/code/issues/882
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"id(web): prosemirror_to_markdown keeps only the first text node of a code_block — multi-node blocks are truncated on save","articleBody":"## Bug\n\nIn `pkgs/id/src/web/markdown.rs`, `json_to_ast`'s `\"code_block\"` arm reads only the **first** text child of the ProseMirror code block:\n\n```rust\n// markdown.rs:~638-642 (main 45c817e0)\nlet content = json[\"content\"]\n .as_array()\n .and_then(|arr| arr.first())\n .and_then(|n| n[\"text\"].as_str())\n .unwrap_or(\"\");\n```\n\nA code block whose ProseMirror content is split into more than one text node — which editors produce legitimately, e.g. after collaborative merges, paste operations, or syntax-token boundaries in the client — silently loses every node after the first on save.\n\n## Verified repro (this run, main 45c817e0)\n\nTemporary probe test run with `cargo test --features web --lib web::markdown::` (probe removed after the run; assertion below is the acceptance test):\n\nProseMirror input:\n\n```json\n{\n \"type\": \"doc\",\n \"content\": [{\n \"type\": \"code_block\",\n \"attrs\": {\"params\": \"rust\"},\n \"content\": [\n {\"type\": \"text\", \"text\": \"fn a() {}\\n\"},\n {\"type\": \"text\", \"text\": \"fn b() {}\"}\n ]\n }]\n}\n```\n\n`prosemirror_to_markdown` emits:\n\n````\n```rust\nfn a() {}\n```\n````\n\n`fn b() {}` is deleted with no error. (The single-node form the codec's own parser produces works, which is why the existing tests — e.g. `test_pm_to_md_table`-era code-block tests — never caught this: the loss only appears once a real editor or a collab peer splits the text.)\n\n## Why it matters\n\nThis is the save path for the id web editor, and `id` is a collaborative system: a code block edited by multiple peers is exactly the content most likely to arrive as several text nodes. Saving silently truncates the block to its first node — data loss in the same codec family as #872/#873/#879/#880/#881, but a distinct arm (`code_block` in `json_to_ast`).\n\n## Suggested fix\n\nConcatenate the `text` of **all** children of the code block (skipping/handling non-text children the same way the first-child code does today — i.e. treat a missing `text` as empty rather than aborting), e.g.:\n\n```rust\nlet content = json[\"content\"].as_array().map_or(String::new(), |arr| {\n arr.iter().filter_map(|n| n[\"text\"].as_str()).collect()\n});\n```\n\nand keep the existing `format!(\"{content}\\n\")` literal construction.\n\n## Acceptance criteria\n\n- [ ] Regression test: a `code_block` with two or more text children round-trips with all text present, in order.\n- [ ] Single-node and empty code blocks behave exactly as before.\n- [ ] Existing `web::markdown` tests still pass (`cargo test --features web --lib web::markdown::`).\n- [ ] Coordination: PR #878 (for #872/#873) is in flight in the same file — sequence or rebase so the img-codec changes do not conflict.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-25T13:24:04Z","url":"https://github.com/developing-today/code/issues/882"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fff4f3b1-8d3a-e6fe-20c2-c46e08259e2d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B55A:EC78C:AADCC7:E41165:6B06413B |
| html-safe-nonce | 42e43e259efc0060574a4a225441fd42917825467c152f0e59f2fc7c472c7db0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTVBOkVDNzhDOkFBRENDNzpFNDExNjU6NkIwNjQxM0IiLCJ2aXNpdG9yX2lkIjoiMzc2ODMwMDY3ODMzNTA1NDEzOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cae146df31aa39ae4dc51a2943440f68ae24405026e40fecc32690a3f3bbf69d |
| hovercard-subject-tag | issue:6024918999 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/882/issue_layout |
| twitter:image | https://opengraph.githubassets.com/043dc54c75a1813774281087e53b9f027233706da7ec21f291a494e042c35910/developing-today/code/issues/882 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/043dc54c75a1813774281087e53b9f027233706da7ec21f291a494e042c35910/developing-today/code/issues/882 |
| og:image:alt | Bug In pkgs/id/src/web/markdown.rs, json_to_ast's "code_block" arm reads only the first text child of the ProseMirror code block: // markdown.rs:~638-642 (main 45c817e0) let content = json["content... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1bff4f6bfaa96dc9c42cacf315424c24ebb548b06142ced5e3aaccb2a42dd652 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ac613d3698d3d8565651455086e1f74da07bf277 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width