I want to add line breaks and link support in the a post

merged…
osebo28d ago

I want to add line breaks and link support in the a post

3 repliesoldestnewest
Osebotfable-5-128d ago

Looked at how post bodies render today (components/markdown.tsx, used by the thread page and the home reply cards):

  • Links: already live via remark-gfm (bare https://… and [text](url) both become anchors). So "link support" mostly works; I'll double-check and keep it.
  • Line breaks: this is the real gap. Markdown collapses a single Enter into a space, so a reply typed as several lines comes out as one paragraph unless you leave a blank line. Fix: add remark-breaks, which turns every newline inside a paragraph into a <br>, matching what people expect from a textarea.

Plan: add remark-breaks to the shared Markdown component (one place, so thread posts and the "last reply" cards agree), verify with a quick render of a multi-line post with links, run tsc/lint, commit + push.

Osebotfable-5-128d agothreadide@ea4d23d

Done, pushed to thread/6d2c9fcd (ea4d23d).

What changed

  • threadide/components/markdown.tsx: added remark-breaks to the plugin list ([remarkGfm, remarkBreaks]). Every newline inside a paragraph now renders as <br>, so a reply typed as several lines keeps its lines. Before, CommonMark folded single Enters into spaces and you needed a blank line to get a break.
  • package.json / lock: remark-breaks@4.0.0.

Links were already working through remark-gfm (bare https://… / www.… autolink, [text](url) too; external links open in a new tab, /threads/… paths stay in-tab). I verified rather than touched that part.

Because Markdown is the one renderer, the thread page and the home "last reply" cards behave the same. Existing posts with single newlines will show them from now on, which is the point.

Verified: server-rendered a sample body (lines → <br>, blank line → new paragraph, lists and fenced code untouched, links → anchors); tsc --noEmit clean. Screenshot attached is the same post before/after. Not run in the live app (needs Postgres + OAuth).

Same post body rendered before (lines collapse into one paragraph) and after (each Enter is a line break; links are anchors)
Same post body rendered before (lines collapse into one paragraph) and after (each Enter is a line break; links are anchors)
Osebot28d ago

Merged threadide #166 by @osebo (merge, ac81f3f).