Skip to content

fix(id): hoist delimiter-mark edge spaces touched by word chars on save (#1418) - #1510

Merged
dezren39 merged 2 commits into
mainfrom
queue/1485-1418-edge-space-mark
Oct 28, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/1485-1418-edge-space-mark

Conversation

@dezren39

@dezren39 dezren39 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Fixes #1418.

Problem

A delimiter-mark span (em/strong/strikethrough) whose text starts or ends with a space saved with the space inside the delimiters; comrak renders it as an   entity (a* b*). When a word character touches the span on that side, that form fails CommonMark flanking rules on reparse — the mark is destroyed and literal delimiters are left in the text (and escaped on the next save).

Fix

AST post-pass in prosemirror_to_markdown (hoist_delimiter_edge_spaces in pkgs/id/src/web/markdown.rs), running after #968 chain merging so only true span edges are considered — an edge space shared with a neighbouring run of the same span is interior there, not an edge. For each delimiter wrapper, an edge space with a word character immediately outside it on that side is moved to a plain text node just outside the wrapper (still inside any outer link wrapper). The space becomes unmarked, which renders identically, and the saved form reparses with the mark intact.

Edges a word character does not touch (paragraph boundary, space/punctuation neighbours, spans padded on both edges) keep the   form, which round-trips PM-identical as before. Link and code marks are untouched (their syntax tolerates edge spaces). Marks wrapping images / spanning html_inline (#1407/#1412) are different mechanisms and unchanged.

Tests

New regression tests in pkgs/id/src/web/markdown.rs:

  • em / strong / strikethrough / em+strong × leading edge × word neighbour: saved form, reopened doc, byte fixpoint
  • trailing-edge mirror (a + em(b ) + c)
  • heading context
  • controls: both-edges padded span, space neighbour, paragraph boundary keep the entity form PM-identical

Verified on the laptop worktree: cargo test --offline --features web --lib web::markdown — 89 passed, 0 failed (includes the existing #953/#968/#981 mark tests). Note: a fresh worktree needs a pkgs/id/web/dist present for the RustEmbed derive to compile locally; a placeholder dist was used locally only (gitignored, not in this PR) — CI builds the real assets.

Queue task 1485 (repo-health-code-pilot).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…ve (#1418)

A delimiter-mark span (em/strong/strikethrough) whose text starts or ends with a space saved with the space inside the delimiters, which comrak renders as an   entity (a* b*). When a word character touches the span on that side, that form fails CommonMark flanking rules on reparse and the mark is destroyed, leaving literal delimiters in the text.

Add an AST post-pass in prosemirror_to_markdown (after #968 chain merging, so only true span edges are considered): for each delimiter wrapper, an edge space with a word character immediately outside it on that side is moved to a plain text node just outside the wrapper (still inside any outer link). The space becomes unmarked, which renders identically, and the saved form reparses with the mark intact. Edges a word character does not touch keep the   form, which round-trips PM-identical as before.

Tests: web::markdown matrix for em/strong/strikethrough/em+strong x leading/trailing edge x word neighbour, in paragraphs and headings, plus controls (both-edges padded, space neighbour, paragraph boundary). 89 web::markdown tests pass on the laptop (cargo test --offline --features web --lib web::markdown).
@dezren39
dezren39 requested a review from a team as a code owner October 27, 2026 19:40
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T00:50:59.637624Z d99b6dd New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5b1e831b-487c-4dc5-8fc2-d2f3fdf7b4a8
Commits

Reviewing files that changed from the base of the PR and between 931f177 and d99b6dd.

Files selected for processing: 1
  • pkgs/id/src/web/markdown.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dezren39

Copy link
Copy Markdown
Member Author

🤖 Agent note · parked

@dezren39
dezren39 merged commit dd9eb97 into main Oct 28, 2026
58 of 60 checks passed
@dezren39
dezren39 deleted the queue/1485-1418-edge-space-mark branch October 28, 2026 03:09
@dezren39
dezren39 restored the queue/1485-1418-edge-space-mark branch November 1, 2026 07:49
@dezren39
dezren39 deleted the queue/1485-1418-edge-space-mark branch November 1, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

id(web): a marked span starting or ending with a space loses its mark on reopen when a word character touches it — saved   form cannot reparse

1 participant