Obsidian plugin API does not support rendering of embeds?

Obsidian plugin API provides a direct way to render markdown anywhere you want - it’s called MarkdownRenderer.renderMarkdown(source, ...). This API unfortunately doesn’t work for link embeds, so plugins can’t render embeds.

Please consider supporting the rendering of embeds. After all, this is a feature that’s already in obsidian.

Raising issue in issue discussion of dataviewjs plugin for visibility (Is is possible to embed the files in the list view ? · Issue #177 · blacksmithgu/obsidian-dataview · GitHub)

19 Likes

This is essential to replicate Roam’s Daily Notes view and will allow us to build personalized feeds.

I’m using a Plugin to convert Notes to Anki. I know two good working plugins, but both do have at least one open issue for this, see Obsidian2Anki and flashcards-obsidian.

I thought of implementing this into one of this plugins myself, but saw some issues I’m afraid of: Embed specific ![[abc#^blocks]], which can have multiple lines etc. There is a regex in Obsidian already to render the embeds, and all plugins should be able to use it.

I’ll link this thread in the issues. I’ll use embeds. I’ll wait for someone to contribute so my Anki cards will show the actual content…

1 Like

Thank you for referring to the issue I opened on flashcards-obsidian repository. I’ve been waiting for months for this functionality and I don’t understand why nobody else thinks it’s important. Even, I stopped to create the flashcards, as I believe it’s fundamental.
I’d love to see it in the Obsidian roadmap; I’m probably not alone.

Working on it too with dbfolder plugin here

1 Like

Just going through the above plugins in the order they were mentioned:

  1. @Yummy: blacksmithgu/obsidian-dataview issue #177: still open, unresolved.
  2. @hashishin: Pseudonium/Obsidian_to_Anki issue #347: still open, unresolved.
  3. @hashishin & @Klaudi0z: reuseman/flashcards-obsidian issue #74: resolved with a hacky fix – finds embeds in rendered HTML using internal-embed class, converts HTML into Markdown using showdown, which may result in unwanted side effects.
  4. @RafaelGB: RafaelGB/obsidian-db-folder issue #136: resolved by using MarkdownPreviewView.renderMarkdown instead of MarkdownRenderer.renderMarkdown when cell contents begin and end with embed syntax.

[edit: new user, can only post 5 links]

1 Like

I created a custom solution for rendering embeds in Obsidian-rendered markdown. Here’s the source code in my repeat plugin: obsidian-repeat-plugin/markdown.ts at ad2097cde7c337a2ee04b48083cd12e0d680b5a2 · prncc/obsidian-repeat-plugin · GitHub

The basic idea is to first render with MarkdownPreviewView.renderMarkdown and then fix broken embeds (with direct DOM manipulations) using a sequence of cases like:

 const embedType = determineEmbedType(node);
    if (embedType === EmbedType.Image) {
      const img = createEl('img');
      img.src = getMediaUri(
        vault,
        node.getAttribute('src') as string,
        sourcePath);
      node.empty();
      node.appendChild(img);
    }

The tricky part is figuring out the URLs.

At this time, I only embed PDFs on desktops because it looks like mobile Obsidian uses native-systems to embed PDFs and it wasn’t worth the time investment to support a feature I don’t use that much. Also, I don’t recursively render notes embedded in the embedded note, although it wouldn’t be to complicated to do so.

just here to let you know that I just made a permanent and proper fix in obsidian-dataview that just needs to be pulled and published.
see Fix: markdown render api change due to deprecation by GottZ · Pull Request #2266 · blacksmithgu/obsidian-dataview (github.com) for review.

this is deprecated:
obsidian.MarkdownRenderer.renderMarkdown(markdown, subcontainer, sourcePath, component);

this is not:
obsidian.MarkdownRenderer.render(app, markdown, subcontainer, sourcePath, component);

guess what works out of the box… :smiley:

1 Like

I totally think it is important. So far, I did not manage to render embed images using MarkdownRenderer.renderMarkdown. I wish I could use this feature in some of the plugins I developed.