aliquote.org

August 6, 2024

I wanted to get rid of raw <img> tags and replace then with <figure>, available as a shortcode in Hugo. It turned out I had a lot of replacements to perform:

» rg -nc "\!\[.*\]\(" content/post | cut -d: -f2 | paste -sd+ | bc
688

Here’s a classical one-liner using Sed:

sed "s/^\!\[.*\](\(.*\))/{{< figure src=\"\1\" >}}/ content/post/*.md

I took the opportunity to add a small colored insert to each figure using the following CSS code:

figure {
  box-shadow: 0 0 0 .5em #f3f3ed;
  margin: 2em 4em;
}