add markup to text at given ranges