While working on my Ink plugin for Obsidian, I was attempting to convert the embeds to work off standard SVG files, however, I was struggling to get the correct file path to the SVG file when interpreting the markdown.
A markdown embed looks like the below. You wouldn’t realise it but this test.svg sits in a folder call folder-name. Obsidian doesn’t put that part in because, in this case, it’s the only file in the vault with the name test.svg, so it knows it can figure out the path later.

The problem is, when I grabbed that path to try and show it with my custom html code. I didn’t know how to get the correct path myself. I ran it through the below functions, but they didn’t work as I expected.
// filepath = test.svg
const normedPath = normalizePath( filepath )
const fullPath = plugin.app.vault.adapter.getResourcePath( nPath );
The getResourcePath function converts the path to an absolute path on your hard drive, but it’s missing the folder name. You need to get the relative path to the vault root before passing it to getResourcePath.
/* Output */
app://239482395865/Users/username/vault-name/test-svg.svg
/* Should be */
app://239482395865/Users/username/vault-name/**folder-name**/test-svg.svg`
Note: normalizePath is used to handle any spaces and other odd characters in paths.
