Vim HTML img tag to markdown
DATE: 2020-06-30
AUTHOR: John L. Godlee
I was quite proud of myself for figuring this one out in only about 2 minutes, in Vim. Starting with an HTML img tag:
<img src="img/jetz_table.png" alt="Functional diversity measures" width="640">
And using this Vim regex:
s/<img src="\(.\{-}\)".*alt="\(.\{-}\)".*//g
To create this Markdown formatted image link:

This was my first proper outing using \{-} for non-greedy matching, used on the double quotes ". It also uses capture groups \(.{-}\) -> \1.
Response: 20 (Success), text/gemini
| Original URL | gemini://republic.circumlunar.space/users/johngodlee/post... |
|---|---|
| Status Code | 20 (Success) |
| Content-Type | text/gemini; charset=utf-8 |