Skip to content

Render dev disaster bodies as markdown, not plain paragraphs - #41

Merged
michaeljolley merged 1 commit into
mainfrom
dev/mjolley/markdown-in-disaster-bodies
Aug 7, 2026
Merged

Render dev disaster bodies as markdown, not plain paragraphs#41
michaeljolley merged 1 commit into
mainfrom
dev/mjolley/markdown-in-disaster-bodies

Conversation

@michaeljolley

Copy link
Copy Markdown
Collaborator

What

Dev disaster story bodies were split on blank lines into paragraphs and drawn as plain text. Any markdown typed into the submit form (bold, links, code fences) came through literally instead of being rendered.

Why

Comments already had a safe markdown renderer in src/lib/markdown.ts - built from marked's token stream with an allow list of eight tags, headings demoted to bold paragraphs, and code fences highlighted through shiki. There was no reason for a disaster body to have a second, weaker renderer, so it now goes through the same one.

Changes

  • Disaster.body is now a rendered HTML string instead of string[] paragraphs.
  • paragraphs() is gone; renderBody() takes its place and calls renderComment from src/lib/markdown.ts.
  • shapeDisasters is now async, since rendering a body is.
  • The dev disaster page renders the body with set:html instead of mapping paragraphs.
  • Tests updated to cover markdown rendering (bold text, heading demotion) instead of the old paragraph-splitting behavior.

Testing

  • pnpm test - all 379 tests pass
  • pnpm check - 0 errors, 0 warnings
  • pnpm build - succeeds, pnpm check:dist clean

Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com

Disaster story bodies were split on blank lines into paragraphs and
drawn as plain text, so any markdown someone typed into the submit
form (bold, links, code fences) came through literally instead of
being rendered.

Comments already had a safe markdown renderer in src/lib/markdown.ts,
built from marked's token stream with an allow list of eight tags,
headings demoted to bold paragraphs, and code fences highlighted
through shiki. There was no reason for a disaster body to have a
second, weaker renderer, so it now goes through the same one.

shapeDisasters is async now, since rendering a body is. paragraphs()
is gone; renderBody() takes its place and calls renderComment.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@michaeljolley
michaeljolley merged commit 787cb99 into main Aug 7, 2026
9 checks passed
@michaeljolley
michaeljolley deleted the dev/mjolley/markdown-in-disaster-bodies branch August 7, 2026 21:32
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