Skip to content

fix: preserve Markdown formatting and allow source-mode repairs - #1255

Merged
nedtwigg merged 5 commits into
mainfrom
fix/issue-1254
Oct 21, 2026
Merged

nedtwigg merged 5 commits into
mainfrom
fix/issue-1254

Conversation

@dormouse-bot

@dormouse-bot dormouse-bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1254.

Editing and saving Markdown now keeps simple standalone bracket labels such as [Unreleased] and [1.3.0], writes literal angle brackets in text as entities so <your relay> survives rich-text/source round trips, and preserves recognized headings' existing blank-line choice. New or renamed headings follow the document's majority spacing. Ambiguous bracket syntax retains the serializer's escapes; links, reference definitions, task-like list text, code, and HTML keep their meaning. This is a small serializer customization, not a lossless Markdown editor.

After an import error, the viewer clears MDXEditor's initial-normalization flag so source edits count as edits. Claude's simplify pass removed the duplicate local flag, and dormouse-bot's follow-up preserves text that intentionally spells out numeric entities such as <. Users can repair the file, save it, and switch back to rich text. The owning spec and rationale now cover both recovery and formatting.

Validation:

  • Built and typechecked dor-tools-builtin.
  • Built-in Tools suite: 170 passed, 3 Windows-only tests skipped on macOS, including 22 new serializer regression tests using MDXEditor's installed parser/serializer dependencies.
  • pnpm lint:specs, pnpm lint:md, and git diff --check passed.
  • Tested in innerdogfood: edited rich text and verified the saved bytes retain bracket labels, angle-bracket entities, and mixed heading spacing; switched source → rich text and reloaded successfully. Opened an unparseable <your relay> fixture, repaired it to entities in source mode, verified Save became enabled, saved, returned to rich text, and reloaded successfully.

MDXEditor clears its initial-normalization flag only in its rich-text
export, which a parse error suppresses, so every source edit reached the
viewer as normalization and rebased the session clean: Save stayed
disabled. Once the editor reports a parse error, its changes count as
edits until the next load.

Refs #1254
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 281d126
Status: ✅  Deploy successful!
Preview URL: https://4cbd9bcf.mouseterm.pages.dev
Branch Preview URL: https://fix-issue-1254.mouseterm.pages.dev

View logs

@nedtwigg nedtwigg changed the title fix: let source edits to an unparseable Markdown file be saved fix: preserve Markdown formatting and allow source-mode repairs Oct 20, 2026

@dormouse-bot dormouse-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One finding inline: the entity rewrite in the text handler changes literal &#x3C; / &#x3E; text on save. I'm pushing the suggested fix along with a regression test.

Comment thread dor-tools-builtin/viewer/markdown-format.ts Outdated
dormouse-bot and others added 3 commits October 20, 2026 23:54
…f shadowing it

Publish initialMarkdownNormalize$ false from onError rather than keeping a
module-level unparsed flag that apply() had to reset. Resolve the format
test's MDXEditor dependencies from the viewer, as markdown-dependencies does,
and drop an assertion the preceding one already implied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nedtwigg
nedtwigg merged commit d33522b into main Oct 21, 2026
13 checks passed
@nedtwigg
nedtwigg deleted the fix/issue-1254 branch October 21, 2026 00:33

This branch was successfully deployed

No deployments
hosted-preview — 281d126e Deployed Oct 21, 2026 by nedtwigg via cleanup #1713
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.

markdown editor formatting problems

2 participants