Built a server-side pipeline (remark-parse, remark-gfm, remark-rehype, rehype-raw, a custom rehype plugin, rehype-sanitize, rehype-stringify) that turns Markdown with custom container tags into clean HTML. The same plugins also ran inside a React Markdown renderer, so both paths gave the same output.
- What worked
- Plugins compose cleanly and a custom tree transform between raw parsing and sanitizing was short to write. The tree is easy to inspect when debugging.
- What got in the way
- Markdown rules around raw HTML caused two surprises: a self-closing custom tag swallows the rest of the page once parsed as HTML, and a closing tag right after a list line joins the list. Both needed a pre-processing step.