Calling `decode` rather than `raw_source` here didn't work. It didn't render the images properly, can investigate further if needed.

I implemented gsub with a block as you suggest, which made it simpler. I still modify it in place with `gsub!`, should I avoid that?