Convert local <img src="filename.jpg"> tags to MD links?

What I am trying to do

I am trying to migrate from Joplin to Obsidian. Unfortunatelly, the html links to local assets like <img src="…/path/to/file.jpg" … > are not supported by Obsidian.

Joplin uses multimarkdown link style for any image that I have resized for viewing.

What I have tried

  1. joplin2obsidian: this keeps IMG links as they are.

  2. Joplin’s export as MD + Frontmatter & Yanom: this works well with converting multimarkdown IMG to obsidian MD links, unfortunatelly all Frontmatter tags are lost. (I tried also other combinations like pandoc_md to obsidian, to Qownnotes etc.)

  3. I have searched for various Obsidian plugins but I have not found any.

Ideas?

I’d guess that as a last resort I could try to write sed / awk script to convert IMG to MD links, yet I am not very skilled with that task…

I’m afraid I don’t have a better answer than sed or awk, but maybe file an issue with joplin2obsidian if there isn’t one already.

joplin2obsidian has not been updated in a while.

I gave another try to Yanom and almost succeeded:

  1. Export all notes from Joplin as MD+Frontmatter
  2. Run Yanom with:
    • input markdown, multimarkdown
    • output obsidian
    • tags: leave blank to convert all tags

This works pretty well, the only problem are spaces in file names of linked attachments. A solution is described here:

Which I hope I will be able to resolve via sed. (I prefer ![Some link](<asset with spaces.jpg>).

BTW, compiling Yanom in Linux looks like quite a task, so I ran the pre-compiled Windows binary with WINE.

1 Like

This is the script I ran to adjust the links (all of them, not just to files with spaces):

while IFS= read -r line;
do
 echo "$line"
 sed -e '[email protected]\(\!\[[^]]*\](\)\([^)]*\)@\1<\2>@g' -i "$line" 
done < <(find . -type f -name '*.md')

It works also on multiple MD links in a single line.

Almost unreadable syntax: it looks for anything between ![]() and modifies it to ![](<>).

sed works line by line, so the links must be on a single line (not even sure if MD allows line break within the link).

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.