Skip to content

Port upstream soft break export fix#66

Closed
Renakoni wants to merge 1 commit into
mainfrom
sync/upstream-4844-soft-break-export
Closed

Port upstream soft break export fix#66
Renakoni wants to merge 1 commit into
mainfrom
sync/upstream-4844-soft-break-export

Conversation

@Renakoni

@Renakoni Renakoni commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Port upstream MarkText PR #4844 into the Android Muya copy.
  • Preserve soft line breaks in exported HTML by rendering paragraph and tight-list content with white-space: pre-wrap.
  • Add regression coverage that soft breaks remain conformant newlines instead of becoming <br>.

Upstream Source

Android Relevance

The Android repo carries Muya's HTML export implementation and stylesheet. A soft line break is represented as a bare newline inside a paragraph or tight list item. The live editor shows it because editor content uses pre-wrap behavior, but exported HTML could collapse it into a space. This keeps the embedded Muya export path consistent with editor rendering without changing the CommonMark HTML produced by getHighlightHtml().

Change Details

  • Add export CSS for .markdown-body p and tight list items (li:not(:has(> p))) to use white-space: pre-wrap.
  • Avoid applying that rule to loose list item containers so pretty-printed paragraph/list newlines do not become visible blank lines.
  • Add softBreakExportHtml.spec.ts asserting soft breaks remain newlines and hard breaks still render as <br>.

Verification

  • pnpm --dir third_party/muya exec vitest run src/state/__tests__/softBreakExportHtml.spec.ts passed.
  • pnpm build passed.

@Renakoni

Copy link
Copy Markdown
Owner Author

Reviewed for the Android client: this fix lands entirely in Muya's HTML-export path (exportStyle.css, consumed only by MarkdownToHtml). The Android app has no code path that reaches exported HTML today — MarkdownToHtml appears only in an ambient type declaration, never called; sharing uses Markdown text/files and the live editor does not use the export stylesheet. Upstream, this serves the desktop export/print feature.

Recommendation: close as desktop-only surface for now. If an "export/share as HTML" feature ever lands on Android, this port can be revived from upstream #4844 — the change itself is a safe, CSS-only addition with a regression spec, so nothing blocks re-porting later.

@Renakoni Renakoni closed this Jul 10, 2026
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