Create a Markdown Link -- [URL Title](URL) -- for a URL in the Clipboard

Hi Brian,

That version of the macro looks ancient. In general, using bash to get the title is tricky; Python would be much more reliable. That said, I use this along with some regular expressions (trim whitespace, trim return, …) to get the title:

#!/bin/bash

/usr/local/bin/wget -qO- "$KMVAR_URL__URL" | /usr/local/bin/gawk -v IGNORECASE=1 -v RS='</title' 'RT{gsub(/.*<title[^>]*>/,"");print;exit}'

It works with your example and should cover most cases.

Cheers,
Patrick