datopian / remark-wiki-link-plus

Parse and render wiki-style links in markdown especially Obsidian style links.
MIT License
29 stars 6 forks source link

File embedding e.g. image, pdf, audio etc using transclusion syntax #3

Open rufuspollock opened 2 years ago

rufuspollock commented 2 years ago

See https://help.obsidian.md/How+to/Embed+files

You can embed attachment files like images or audio in your notes. Use the ![[filename.png]] syntax like so

File types supported (note we may support more e.g. everything web browser supports)

Obsidian recognizes the following file formats right now:

Markdown files: md; Image files: png, jpg, jpeg, gif, bmp, svg; Audio files: mp3, webm, wav, m4a, ogg, 3gp, flac; Video files: mp4, webm, ogv, mov, mkv; PDF files: pdf.

Acceptance

ispringle commented 1 year ago

I've been stumped on the transclusion of MD content in my own personal remark plugin for Obsidian. Major issue is it's a cart-horse problem since you can't know what to embed into that transclusion until after it's been parsed. I've had a few ideas to solve this, thought I'd share:

  1. Use an iframe this is the gross way, but it'd work
  2. Move this to a rehype plugin
  3. Attempt to parse the transcluded file

The first idea is bad and shouldn't be used.

The second idea is cumbersome, but ought to be largely foolproof. Just insert a node in place of the transcluded MD syntax and then in a rehype plugin grab that freshly parsed content and embed it.

The third is what I am using (and the remark-obsidian plugin is as well) but it's got a lot of edge cases and other issues.

rufuspollock commented 1 year ago

@ispringle very useful analysis. Agree this one (i.e. full page embedding) is not simple.