Skip to content

feat(announcements): honour the line breaks an author actually typed - #30

Merged
KruGoL merged 1 commit into
mainfrom
feat/markdown-hard-breaks
Aug 10, 2026
Merged

feat(announcements): honour the line breaks an author actually typed#30
KruGoL merged 1 commit into
mainfrom
feat/markdown-hard-breaks

Conversation

@KruGoL

@KruGoL KruGoL commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

The surprise

An author writes this in the composer's Body:

Test Test Test Test Test
TestTestTestTestTest

and the reader gets one line: "Test Test Test Test Test TestTestTestTestTest".

That is markdown behaving exactly as specified — a single newline is a soft break, rendered as a space; only a blank line or two trailing spaces break a line. It is a reasonable rule for a document format and the wrong one for the field this text is typed into. The Body is a plain textarea with no hint that it is markdown at all, the moderator note the server splices into an approval announcement is typed the same way, and nothing anywhere tells an author that the Enter they just pressed will be discarded.

The fix

remark-breaks, so a newline is the line break the author typed. This is the same resolution comment fields everywhere use, GitHub's included.

It rewrites text nodes only, so fenced code blocks keep their newlines verbatim — there is a test for that, since a <br> injected into a code block would change the code itself. Blank lines still start paragraphs.

Nothing changes server-side: sphere-api's deriveSummary already collapses whitespace when it takes the body's first paragraph for the bell popover, so the row reads the same as before.

Tests

Three new tests in Markdown.test.tsx. The first was verified to fail against main; the other two pin behaviour this must not break:

  • a single newline renders a <br>;
  • a blank line still yields two <p>s;
  • a code block contains no <br> and keeps npm install\nnpm run build intact.

vitest run — 183 passed (24 files). npm run build clean.

@KruGoL
KruGoL merged commit 8790102 into main Aug 10, 2026
2 checks passed
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