Small question. Has anyone come across an elegant way of adding HTML to text based on ranges?
My problem is simple, I have a string of text and several ranges (which can overlap), when the ranges overlap different styling is to be applied, otherwise the ranges are simply styled (i.e. <b> or <u> tags). But the problem is, if I insert tags at the start and the end of the ranges, then the other ranges will no longer be correct.
Currently my approach is to build a list of the "points of interest", i.e. where ranges start or end. And work through it backwards, checking if the given point is in each of the ranges. If it is, then I apply the appropriate style. But this is cumbersome and ugly, as I have to check several different lists of ranges for each given point.