-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(parse and sanitize markdown on server) #1634
Conversation
This reverts commit 8c907ae.
Tests are failing because at certain points in the CMS, we've nested list items (asterisks in markdown evaluate to |
Nice find. Is that a sign of malformed content? I would've hoped that markdown conversion & template replacement to be commutative... |
Nope, unfortunately the content is correct :/ It would be commutative if we were only doing simply text replacements, but since we're executing IF-ELSE logic with conditionals, important HTML gets omitted after it's been parsed/sanitized from markdown |
…thin conditionals
import { useField } from "remix-validated-form"; | ||
import TileTag, { type TileDescriptionProps } from "./TileTag"; | ||
import Image, { type ImageProps } from "../../Image"; | ||
import RichText from "../../RichText"; | ||
|
||
const paragraphRenderer: Partial<Renderer> = { | ||
paragraph({ text }) { | ||
return `<p class="ds-subhead">${text}</p>`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you check if this component renders the RichText
with the paragraph with this className?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a new test suite, richtest.test.ts
, as the rendering is occurring inside of buildRichTextValidation
Quality Gate passedIssues Measures |
This PR shifts the responsibility of parsing and sanitizing markdown from the
<RichText/>
component to the zod schema definitions via.transform()
. To do this, I've added a newbuildRichTextValidation
zod schema type, and replaced all instances ofzod.string()
with it, where applicable. Further cleanup PR to come.