feat(markdown-preview): render HTML and load local images via blob URLs#150
Merged
Conversation
Enables GitHub-style markdown rendering: raw HTML in .md files now renders (via rehype-raw + rehype-sanitize with a GitHub-compatible allowlist), and relative/absolute local image paths load correctly in the Tauri webview by reading bytes through ctx.files.readBytes and serving them as blob URLs — the same pattern used by the image-viewer extension. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
Summary
<img align="left">,<h3>,<br>tags in README files) viarehype-raw+rehype-sanitizewith a GitHub-compatible allowlist./assets/logo.png) now load correctly in the Tauri webview by reading bytes throughctx.files.readBytesand serving them as blob URLs, identical to the pattern used by the image-viewer extensionhttps://img.shields.io/...) pass through unchangedNew files
sanitize-schema.ts— GitHub sanitization schema withsrcprotocol filter removed so local paths reach the custom<img>componentresolveImageSrc.ts— pure helpers (isExternalImageUrl,resolveLocalImagePath) that reuse the existingresolveFilePathfromlinks.tsresolveImageSrc.test.ts— 14 unit tests covering both helpersTest plan
pnpm test— all 141 tests passpnpm --filter silo exec tsc --noEmit— no type errorsREADME.mdin Preview mode — badge images,<img align="left">,<h3>all render (not shown as raw text).mdfile with a relative image path — image loads<script>alert(1)</script>in a.mdfile stays inert🤖 Generated with Claude Code