GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 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

id(web): prosemirror_to_markdown keeps only the first text node of a code_block — multi-node blocks are truncated on save #882

New issue
Copy link
New issue
Copy link
Closed
#888
Closed
id(web): prosemirror_to_markdown keeps only the first text node of a code_block — multi-node blocks are truncated on save#882
#888
Copy link
Assignees
dezren39
Labels
app/idPackage/app: id (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)

Description

@dezren39
dezren39
opened on Oct 25, 2026
Issue body actions

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())
    .and_then(|n| n["text"].as_str())
    .unwrap_or("");

A 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.

Verified repro (this run, main 45c817e)

Temporary probe test run with cargo test --features web --lib web::markdown:: (probe removed after the run; assertion below is the acceptance test):

ProseMirror input:

{
  "type": "doc",
  "content": [{
    "type": "code_block",
    "attrs": {"params": "rust"},
    "content": [
      {"type": "text", "text": "fn a() {}\n"},
      {"type": "text", "text": "fn b() {}"}
    ]
  }]
}

prosemirror_to_markdown emits:

```rust
fn a() {}
```

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.)

Why it matters

This 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).

Suggested fix

Concatenate 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.:

let content = json["content"].as_array().map_or(String::new(), |arr| {
    arr.iter().filter_map(|n| n["text"].as_str()).collect()
});

and keep the existing format!("{content}\n") literal construction.

Acceptance criteria

  • Regression test: a code_block with two or more text children round-trips with all text present, in order.
  • Single-node and empty code blocks behave exactly as before.
  • Existing web::markdown tests still pass (cargo test --features web --lib web::markdown::).
  • Coordination: PR fix(id-web): img attribute codec — sequential parse, escaped emission (#872, #873) #878 (for id(web): parse_img_tag substring search lets data-src/data-width shadow the real img attributes — save rewrites the image URL #872/id(web): prosemirror_to_markdown emits img src/alt/title unescaped — quotes truncate values and can inject attributes on reparse #873) is in flight in the same file — sequence or rebase so the img-codec changes do not conflict.

Activity

  1. github-actions
    assigned
    dezren39
    on Oct 25, 2026
  2. dezren39 commented on Oct 25, 2026

    @dezren39
    dezren39
    on Oct 25, 2026
    MemberAuthor
    More actions

    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: a code_block with text nodes "fn a() {}\n" and "fn b() {}" emits only fn a() {} (plus the usual trailing blank line before the closing fence). The second node is dropped, as filed.

  3. dezren39
    added a commit that references this issue on Oct 25, 2026

    fix(id-web): codec round-trip — linked images, table alignment, multi…

    9cbbb0a
  4. dezren39
    closed this as completedin #888on Oct 25, 2026
  5. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)kind/bugSomething isn't working (prefixed form of the classic bug label)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.