Idea for new, improved renderer: - Break each line down into an array of objects, one object per character. This should happen after UTF-8 conversion. - Objects have properties for color, style, etc. - ANSI converter runs through the array, removing control characters and setting appropriate styles. - Catenate all the characters to get a 'stripped' string for pattern matching. * - Run URL matches. Flag appropriate characters. - Run trigger matches. Set appropriate styles on the corresponding characters in the array, being careful not to split any URLs. - Run through the array, re-assembling it. Look for runs with the same styles or tags, and consolidate. * - Do HTML entities while re-assembling. * May have performance implications. It looks like concatenation is faster than join() here, at least in Chrome.