Render dev disaster bodies as markdown, not plain paragraphs - #41
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.bodyis now a rendered HTML string instead ofstring[]paragraphs.paragraphs()is gone;renderBody()takes its place and callsrenderCommentfromsrc/lib/markdown.ts.shapeDisastersis now async, since rendering a body is.set:htmlinstead of mapping paragraphs.Testing
pnpm test- all 379 tests passpnpm check- 0 errors, 0 warningspnpm build- succeeds,pnpm check:distcleanCo-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com