obsidianmd / obsidian-api

Type definitions for the latest Obsidian API.
https://docs.obsidian.md
MIT License
1.65k stars 192 forks source link

Bug: `MarkdownRenderer.renderMarkdown` does not render embedded images #120

Open ivan-liadniou-epam opened 11 months ago

ivan-liadniou-epam commented 11 months ago

Hello there!

I'm working on a plugin that renders markdown in search views (https://github.com/ivan-lednev/better-search-views), and there is a feature request to render images in search matches the way they're rendered in live preview/reading view. Would such an enhancement be possible?

GitMurf commented 7 months ago

Curious if this is something that is even doable or planned for the API? or if we need to rely on custom implementation to get images to render? the query control plugin renders images but better search views does not. I would prefer to be able to use better search views going forward, but without images rendered it makes it hard to leave query control plugin. Thanks!

lishid commented 7 months ago

I believe the new MarkdownRenderer.render() supports this, assuming you properly manage the lifecycle of the Component being passed in (make sure it's loaded going in, and then unload it when your view is destroyed, or pass it the component of your own, such as a view)

https://github.com/obsidianmd/obsidian-api/blob/791214a68d0dc322b88e5abce617bdf603cc2a2d/obsidian.d.ts#L2245