Repository navigation
Description
Problem
In the id web editor's markdown codec (pkgs/id/src/web/markdown.rs), a fenced code block without an info string is rewritten as an indented (4-space) code block on save. The user's chosen fence form is destroyed on every open→save, even when nothing else changed. An empty fenced block additionally gains a spurious blank line.
Evidence (verified this run)
Round-trip probe on main a2eef6f7 (standalone crate compiling the verbatim pkgs/id/src/web/markdown.rs against comrak 0.56.0 + serde_json; full logs in the goal's hidden_files/probe-2026-10-26-0312/out.log and out3.log):
| Input | Saved output |
|---|---|
``` block with blank lines, no info (```\nline1\n\n\nline2\n```) |
indented block: line1\n \n \n line2 |
```` block containing a ``` line (no info) |
indented block: ```\n inner |
| fenced block (no info) inside a list item | rewritten to a 6-space indented block inside the item |
| fenced block (no info) inside a blockquote | rewritten to indented form (> code line) |
empty fenced block (```\n```) |
```\n\n``` — a blank content line appears |
```rust block with blanks (control, has info) |
stays fenced, unchanged ✓ |
The rewritten forms are currently stable fixpoints (a second round-trip does not degrade them further), so this is a fidelity/diff-noise bug rather than progressive corruption — but the rewrite is unconditional: merely opening and saving a note reformats every info-less fenced block in it.
Root cause (to confirm in triage)
json_to_ast builds every code_block as fenced: true, fence_length: 3 (pkgs/id/src/web/markdown.rs:885-890), yet comrak's format_commonmark renderer still emits the indented form for these blocks — the cases above suggest it does so whenever there is no info string (the rust-info control stays fenced). Separately, the literal is always built as format!("{content}\n") (:890), so an empty block's literal is a single "\n", which renders as the spurious blank line. The existing round-trip test (test_roundtrip_code_block) only covers an info-carrying block, so neither behavior is pinned.
Why it matters
- Silent reformatting on save pollutes diffs in synced/vault notes and erodes trust in the editor's other (correct) round-trips.
- Indented code is context-fragile once the user edits the saved file by hand or in another tool: it cannot interrupt a paragraph, is invisible as a block, and is the form most likely to be mangled by other markdown tooling.
- Info-less fences are the common case for plain shell/output snippets.
Acceptance criteria
- A fenced code block without an info string round-trips open→save still fenced (byte-identical modulo the file's trailing newline), including blocks with blank lines, blocks containing ``` lines, and blocks nested in list items and blockquotes.
- An empty fenced block round-trips with no spurious blank line added.
- Info-carrying blocks and all existing codec tests are unchanged; new unit tests in
pkgs/id/src/web/markdown.rscover the info-less and empty cases. - Saved output is a stable fixpoint on a second round-trip.
Activity
dezren39 commentedon Oct 26, 2026
🤖 Agent note · state: filed
dezren39 commentedon Oct 27, 2026
🤖 Agent note · filed
- item+ twoblocks ("code", "more") → save 1 renders both as one indented region (` code\n\n more`) → re-parse yields a SINGLE code_block with literal `code\n\nmore` (PM2 inspected) → save 2 is that merged block. Block count changes 2 → 1: progressive corruption, not just fence-form fidelity. Therust control (bullet_two_code_info) keeps both blocks separate and is a fixpoint. Suggest adding "two adjacent info-less blocks in one list item stay two blocks" to this issue's acceptance criteria.dezren39 commentedon Nov 2, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 2, 2026
🤖 Agent note · handed off
55 remaining items
dezren39 commentedon Nov 10, 2026
🤖 Agent note · triaged
task/small-fix· priority/low · effort/s ·kind/bugrepo-health:v1:fix:developing-today/code:issue:954→ queuerepo-health-code-pilot, task 14530.dezren39 commentedon Nov 10, 2026
🤖 Agent note · done (triaged, per runbook §1c / #8097 rule 3)
status/needs-triage— the triage step's agent note is on this issue at 2026-11-10T04:42:16Z (verdict: task/small-fix, priority/low, effort/s; first step in pkgs/id/src/web/markdown.rs). Per §1c this packet is bookkeeping only; this lane does not re-triage.triaged. Issue id(web): fenced code blocks without an info string are rewritten as indented blocks on save #954 stays OPEN for its fix packet.dezren39 commentedon Nov 10, 2026
agent-note:v1
lane: code-w
task: 14530
issue: #954
stage: claimed
note: Task 14530 (small_fix, issue #954) picked up by lane code-w (direct, lane row 5991). Fresh check: issue #954 OPEN, no hard-stop labels, no status/needs-triage. Work: fix pkgs/id/src/web/markdown.rs so info-less fenced code blocks round-trip fenced (incl. blank lines, nested fences, list/blockquote nesting) and empty fenced blocks gain no spurious blank line; add unit tests. Next: create laptop worktree, inspect codec, reproduce.
dezren39 commentedon Nov 10, 2026
agent-note:v1
lane: code-w
task: 14530
issue: #954
stage: done
note: Task 14530 (small_fix, issue #954) verified already fixed on main by lane code-w (direct, lane row 5991); closing this issue on that evidence. The fix is present in pkgs/id/src/web/markdown.rs on main e94cf89: render option prefer_fenced forces the fenced spelling for info-less code blocks, json_to_ast builds an empty literal for empty blocks (no spurious blank line), and force_fenced_code_blocks_in_blockquotes covers the blockquote shape (landed via repo-keeper snapshot 7fb1e6d and commit 1ec98d8 for #1496). Verification run on the laptop this shift (cargo test --manifest-path pkgs/id/Cargo.toml --features web --lib, stub dist/ placeholder for RustEmbed): test_roundtrip_info_less_code_block_stays_fenced ok, test_roundtrip_empty_code_block_has_no_spurious_blank_line ok, test_roundtrip_code_block ok, test_info_less_code_block_keeps_following_paragraph_in_blockquote ok; full web::markdown module 266 passed, 0 failed. Every acceptance case (blank lines, fence-containing content, list item, blockquote, empty block, fixpoint) is pinned by those tests. No code change was needed from this task.