Fixing double enhance bug

The previous approach of gsub-ing while identifying text to replace was sometimes causing the replacement text itself to be enhanced. By separating the identification of text to enhance from the application of those enhancements, we can avoid that issue.