GeezerVison is showing github.com — id(web): linked images [](href) lose their link in the markdown ↔ ProseMirror codec — save strips the href · Issue #880 · developing-today/code
id(web): linked images [](href) lose their link in the markdown ↔ ProseMirror codec — save strips the href #880DescriptionBug
In pkgs/id/src/web/markdown.rs, a linked image — [](https://example.com) — loses its link in the markdown ↔ ProseMirror codec, in both directions:
- Parse direction (
convert_node, NodeValue::Link / NodeValue::Image arms, markdown.rs:~291-323 on main 45c817e): a Link node is converted via collect_inline_children, which flattens mark wrappers. The Image child is not a mark wrapper and is converted without the accumulated marks — the image branch never looks at active_marks — so the resulting ProseMirror image node carries only src/alt/title. The href is gone before the editor ever sees the document.
- Save direction (
json_to_ast): there is likewise no representation for an image wrapped in a link, so even a ProseMirror doc that somehow held the link could not emit one.
Verified repro (this run, main 45c817e)
Temporary probe test run with cargo test --features web --lib web::markdown:: (probe removed after the run; assertions below are the acceptance tests):
markdown_to_prosemirror("[](https://example.com)") returns:
{"type":"doc","content":[{"type":"paragraph","content":[{"type":"image","attrs":{"src":"img.png","alt":"alt"}}]}]} — no trace of https://example.com.
prosemirror_to_markdown of that document emits:  — the link target is silently deleted on the first load/save round trip.
Why it matters
Linked images (badges, thumbnails linking to full-size images, screenshot links) are common in notes and docs. Opening such a document in the id web editor and saving it — even with no edits — permanently strips the link. Silent data loss on the save path, in the same codec family as #872/#873/#879 but a distinct node combination (Link wrapping Image).
Suggested fix (either representation is acceptable — pick what the editor schema supports)
- Preferred: when an image is the sole child of a link, represent it in ProseMirror in a form the editor already understands for linked images, and teach
json_to_ast to wrap the emitted NodeValue::Image in a NodeValue::Link for that form.
- Or: carry the link as an attribute on the image node (e.g.
linkHref) through both converters, with json_to_ast wrapping the image in a Link node (or emitting the [](href) form) when the attribute is present.
- Images with additional siblings inside the link (e.g.
[see  now](href)) should keep the existing text-mark behaviour for the text parts and must not crash or drop the image.
Acceptance criteria
Activitydeveloping-today commented on Oct 25, 2026 dezren39 commented on Oct 25, 2026 Verification note from the filer (new-issue-creator): this issue was re-verified in a corrected probe run on main 45c817e and genuinely reproduces.
Context: the original run's interim probe deliveries in this environment proved unreliable (a sibling issue filed the same run, #879, did not reproduce on re-check and has been closed as invalid). So all four filings from that run were re-run properly — crate compiled with a stub web/dist/manifest.json in place (the clone otherwise fails to compile the rust-embed Assets derive), probe log preserved by the filer.
For this issue the re-run shows exactly the reported behaviour: the ProseMirror document for [](https://example.com) is a bare image node ({"attrs":{"alt":"alt","src":"img.png"},"type":"image"} — no href anywhere), and prosemirror_to_markdown emits . The link is lost, as filed.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|