I've been slowly converting a blog of mine to markdown. The final thing to do is replacing all the html anchors with markdown.
I've come up this sed regex, which for all intents and purposes should do what I want, but it doesn't.
Source data:
$ cat /tmp/test
on <a href="https://www.reddit.com/" target="_blank" rel="noopener">reddit</a> or <a href="https://lifehacker.com/" target="_blank" rel="noopener">Lifehacker</a>
Sed command:
$ sed -r 's/<a.*?href="(.*?)".*?>(.*?)<\/a>/[\2](\1)/g' /tmp/test
on [Lifehacker](https://lifehacker.com/" target="_blank" rel="noopener)
What I want it to return:
on [Reddit](https://reddit.com/) or [Lifehacker](https://lifehacker.com/")
/tmp/test
or is that wrapping? – Quasímodo Apr 25 '20 at 11:01.*?
with[^"]*
. – meuh Apr 25 '20 at 11:33pandoc -f html -t markdown /tmp/test
. – fra-san Apr 25 '20 at 11:45sed
, but it requires some work. – fra-san Apr 25 '20 at 12:13