MarkdownRenderer produces inconsistent output for embedded notes

I’m using MarkdownRenderer to render user-provided markdown in a custom code block (using registerMarkdownCodeBlockProcessor).

For the most part, it works great, but I did notice a major visual bug in the rendered markdown.
Specifically, it’s a bug in the rendering of Embedded notes.

An embedded note using the default dark theme should look like this:

Using MarkdownRenderer on the same input, I get this:

For some reason the padding in the embed only gets applied to the note’s name and not to its contents.

This is a major bug for developers trying to provide a consistent experience to users.

For reference, I did a stress test on all documented markdown features, and this is the only issue I could find for now.

I suggest you to try the hacky version that I made, that supposedly makes MarkdownRenderer to behave closer to the internal obsidian rendererer.

import { fullRender } from 'obsidian-dev-utils/obsidian/Markdown';

await fullRender({
  app,
  el,
  markdown
});

Thanks for the suggestion.

I tried your hack but it doesn’t render embeds at all.
My goal is to incorporate all the Markdown functionality Obsidian provides.

On top of that, installing obsidian-dev-utils installs over 600 new packages!!!

I think an official fix is really the way the to go here.

Interesting, I originally wrote that helper specially to address embeds. Maybe internals changed since then.

Regarding 600 dependencies, yes, the library wasn’t designed to be small. It has bunch of helpers but not size-efficient

For now I found a fix by just adding the following CSS:

.my-markdown-container .markdown-embed .markdown-preview-view {
    padding: var(--embed-padding);
}

It seems somewhere down the line the padding is being set to 0.

This should be fixed in 1.11.2. Let me know if you’re still seeing inconsistent output!

1 Like

Just tested it and the issues seems to be fixed.
Thanks, @liam!