Use Trix-compatible HTML for proper paragraph spacing#421
Use Trix-compatible HTML for proper paragraph spacing#421nnemirovsky wants to merge 3 commits intobasecamp:mainfrom
Conversation
MarkdownToHTML previously wrapped paragraphs in <p> tags and inserted bare <br> between blocks. Basecamp's Trix editor uses <div> blocks with <div><br></div> for empty lines, so <p>-based output rendered with incorrect spacing: either double-spaced (with <br>) or no spacing at all (without). Three changes: - Paragraphs use <div> instead of <p> to match Trix's native format - Blank lines produce <div><br></div> (Trix's empty line separator) - Consecutive lines preserve line breaks via <br> instead of joining with spaces, so single newlines render as visible line breaks
There was a problem hiding this comment.
Pull request overview
Updates the rich-text Markdown→HTML conversion to match Basecamp/Trix’s native HTML structure so paragraph spacing and single line breaks render consistently in Basecamp.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Changes:
- Switch paragraph wrapper output from
<p>to Trix-style<div>. - Represent blank lines as
<div><br></div>instead of emitting a standalone<br>. - Preserve single newlines inside paragraphs by joining lines with
<br>rather than spaces.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| internal/richtext/richtext.go | Emits Trix-compatible <div> blocks and <div><br></div> separators; preserves single newlines via <br>. |
| internal/richtext/richtext_test.go | Updates expected HTML outputs and adjusts round-trip behavior checks for the new line-break handling. |
| internal/commands/checkins_test.go | Updates check-in answer creation test expectation to the new <div>-wrapped content. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/richtext/richtext.go">
<violation number="1" location="internal/richtext/richtext.go:178">
P1: MarkdownToHTML now emits `<div>` paragraphs, but HTMLToMarkdown only normalizes `<p>` blocks, causing paragraph-spacing loss in round-trip conversions.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…und-trip - Add <div><br></div> → blank line and <div> → paragraph handling in HTMLToMarkdown so Trix-native HTML round-trips correctly - Drop trailing \n from <br> join in flushParagraph to prevent double-newlines on round-trip - Strengthen round-trip test to verify line ordering and newline preservation between consecutive lines
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
<div>instead of<p>— Trix uses<div>blocks, not<p>. Using<p>caused either double spacing (with<br>separator) or zero spacing (without) depending on browser CSS.<div><br></div>for blank lines — matches Trix's native empty-line representation, producing consistent single-line paragraph gaps.<br>instead of being joined with a space, so single\nrenders as a visible line break rather than being swallowed.Before:
MarkdownToHTML("Line 1\n\nLine 2")→<p>Line 1</p>\n<br>\n<p>Line 2</p>(double-spaced in Basecamp)After:
MarkdownToHTML("Line 1\n\nLine 2")→<div>Line 1</div>\n<div><br></div>\n<div>Line 2</div>(correct single spacing)Verified by comparing generated HTML against a manually-edited Basecamp comment's HTML (fetched via API) — the output now matches Trix's native format exactly.
Test plan
TestMarkdownToHTML*tests updated and passingTestRoundTripupdated for new line-break preservation behaviorTestCheckinsAnswerCreateupdated for<div>outputSummary by cubic
Switch MarkdownToHTML to output Trix-compatible HTML so Basecamp shows correct paragraph spacing. Also handle Trix-style
<div>in HTMLToMarkdown so content round-trips cleanly.<div>, blank lines as<div><br></div>, and preserve single\nas<br>inside paragraphs.<div><br></div>to blank lines and<div>to paragraphs in HTMLToMarkdown; enable dotall matching for multiline<p>/<div>blocks; avoid extra newlines on round-trip; updated tests and check-ins expectation to the new format.Written for commit 6aa2d47. Summary will update on new commits.