kyprio kyprio - 7 months ago 55
Markdown Question

convert html links to markdown using command sed

I am editing a bash script to convert html into markdown and i found myself stuck with that tag :

<a href="">Link</a>

which should looks like this in markdown



I found something with sed and the pattern selectors \1 \2

echo '<a href="">Link</a>' | sed 's/<a href="\(.*\)">\(.*\)<\/a>/[\2](\1)/'

The pattern you place between parenthesis \( and \) will be stored in a variable \1 then the next one will be in \2 ...