Kludgy, but as the problem's presented (and presuming there's a 1-to-1 mapping from original head elements to marked up head elements):
- Create a hash mapping from original to extra-
crispymarkup head elements (presuming they're small just treat them as two text files and read them line-by-line in parallel)
- Parse the original file and use XML::Twig to walk all the head elements, replacing the contents by looking up the original value in your hash and retrieving the possibly modified version
- Profit!
The cake is a lie.
The cake is a lie.
The cake is a lie.