Skip to content
Source
Sign inSign up
TanStack/markdown

Add option to either allow inline data uri attributes or to provide your own sanitizer/parser #11

Send to my agent
ClosedYuripetusko(GitHub profile, opens in a new tab) opened this issue 1 comment

sanitizeUrl currently replaces img src with empty string ''

If we run our own sanitizer/parser before that to strip out any large data-uris, there's no option to make it so renders them.

  1. tannerlinsley added labelsenhancement

  2. Confirmed on 0.0.14: the string parser removes data: URLs before inline transforms run, and there is no URL-policy callback. That default is intentional; the missing opt-in policy hook is a valid enhancement. Enabling allowHtml is not an appropriate fix for this.

    The existing MarkdownDocument input does support a custom parser: application-validated image nodes can retain data URLs and render in HTML, React, and Octane. The application must validate the AST, image content, MIME types, and payload limits. This does not restore URLs that the built-in string parser has already removed.

    I tested an opt-in callback receiving the original destination and whether it belongs to an image or link. It worked, but added 19 gzip bytes to the parser and 15-19 bytes to the measured renderer entries, so it was not retained under the no-growth constraint. Keeping this open for a size-neutral design that preserves the current default policy and distinguishes image sources from link destinations.

  3. tannerlinsley closed this

Sign in to join this conversation.