Skip to content

feat(files): add optional line break preservation to Markdown preview#343

Open
youxikexue wants to merge 1 commit into
xintaofei:mainfrom
youxikexue:feat/markdown-preview-line-breaks
Open

feat(files): add optional line break preservation to Markdown preview#343
youxikexue wants to merge 1 commit into
xintaofei:mainfrom
youxikexue:feat/markdown-preview-line-breaks

Conversation

@youxikexue

Copy link
Copy Markdown
Contributor

Problem

Markdown preview follows CommonMark/GFM soft-break behavior, so a single physical line break inside a paragraph is rendered as a space.

Reproduction:

  1. Open a Markdown file containing two lines separated by one newline.
  2. Switch from source editing to preview.
  3. The second line appears directly after the first.

This is standard Markdown behavior rather than data loss, but it is inconvenient for users who want AI-generated notes or prose to follow source line breaks.

Solution

Add a device-level Preserve single line breaks option for Markdown file preview.

  • Disabled by default to preserve existing CommonMark/GFM behavior.
  • When enabled, only MarkdownDocumentPreview appends remark-breaks.
  • The preference uses the existing appearance localStorage pattern.
  • The settings UI is isolated from preference and rendering logic, so its placement or wording can be changed independently.

The existing Monaco Enable word wrap option is not reused because it controls visual wrapping of long source lines, not Markdown soft-break semantics.

Impact

  • Does not modify source content, saving, Git diff, Agent messages, or HTML/Office previews.
  • Existing and upgraded users retain current behavior by default.
  • Tables, fenced code blocks, paragraph separation, and existing hard breaks remain unchanged.
  • No backend field or database migration is required.

Verification

  • Added preference tests for default value, persistence, and cross-window synchronization.
  • Added real Streamdown tests for enabled/disabled soft breaks and Markdown structure regressions.
  • All 10 locale message structures pass.
  • ESLint, 185 Vitest files / 2320 tests, and Next.js production build pass.
  • Verified in a Windows Tauri build.
  • Manual shared-web verification remains pending.

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.

1 participant