Markdown: Hover mouse pointer over attachment link to take a quick look at PDF

Here is what I’m looking for while using the Markdown preview pane

  1. Hover mouse pointer over a link like this one: quicklook
  2. See a quicklook preview of the PDF file

Ideas anyone?

I once wrote a script that inserts the Quicklook preview in the MD file using a data URI.
One could perhaps combine that with some CSS and a script to perform the hover action.
I wouldn’t do it, though. A data URL increases file size tremendously and makes it hard to work with the file in edit mode.

Quicklook is something macOS (and perhaps iOS) provides. hover is a function of the browser (or WebKit, in the case of DT). For good reasons, the browser (WebKit) can’t use APIs of the underlying machine directly (think FileManager and your browser reading/sending/deleting files). So, it’s impossible to create a Quicklook image on the fly when you’re hovering. Not to mention that it’s probably not a good idea performance-wise: A user hovering expects an immediate response, not a lengthy (and repeated!) file creation.

Another possibility would be a script that

  • creates the Quicklook images as jpeg/png/whatever files in the same DT group as the MD file
  • adds an img element to the MD file right behind the link to the image
  • adds a style element to the head of the MD file to hide the img elements and reveal them when hovered over

While that’s feasible, it causes trouble when you modify the MD file, adding/changing/removing images because then you’ll have non-functional links.

Conclusion: If you want HTML behavior, use HTML and a browser. It has been conceived for that. Markdown has been conceived to write HTML faster – not to mimic a browser.

Not looking to create a Quicklook image on the fly but rather hoping to view the PDF page that the link refers to in a popover PDF viewer once the mouse pointer hovers over the link…

A PDF viewer is even more demanding than creating a Quicklook preview, I suppose. Anyway, I’ve said all I have to say on that – you’re looking for HTML and browser features in a Markdown environment, and that’s not working.

It turns out that Obsidian has this feature already :slight_smile: