I think we need some tidy up here... Why do we need to check the availability of `text.indexOf` in `escapedStart = text.indexOf && text.indexOf(escapedStartSymbol)`?

Furthermore the nested `if`s can certainly be flatten.