obsidian-api icon indicating copy to clipboard operation
obsidian-api copied to clipboard

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

Open ivan-liadniou-epam opened this issue 2 years ago • 2 comments

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?

ivan-liadniou-epam avatar Jul 20 '23 08:07 ivan-liadniou-epam

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!

GitMurf avatar Nov 10 '23 00:11 GitMurf

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

lishid avatar Nov 14 '23 18:11 lishid