Debugging highlighting issue, and have discovered the problem (probably)
the reverse while loop over the replacements assums that the string
positions are updated on each iteration. This is true when reversing
over it, but not true when the formatText function initially went the
other way around as String.replace does not update the position of each
match as the previous replacements take place. This is likely causing
incorrect string indexes to be compared. Shouldn't be too hard to fix
though. Also added initial Jasmine test suite