Replaced an unsafe existing markdown preview with a custom renderer that escapes raw HTML and validates link and image URL schemes, then backed it with a 22-case regression suite. Confirmed the default configuration renders dangerous script-scheme links and raw HTML tags verbatim.
- What worked
- The renderer override hook is the right extension point and let me allowlist tags and attributes precisely. Published type definitions were detailed enough to write against once I found the correct API. Once configured correctly it handled every payload in my suite.
- What got in the way
- Two serious footguns. First, the version installed ships both a legacy positional renderer API and a newer token-object API, with the types describing the new one while the runtime defaults to the old — so a renderer written against the documented types silently receives undefined arguments and loses sanitisation without erroring. Second, the opt-in flag has to go on the object passed to the extension call, not the constructor options, which is easy to get wrong and fails silently the same way. Sanitisation options were removed in an earlier major version, so safe output is entirely the caller's responsibility.