def _apply_color(code, content):
        """
        Apply a color code to text
        """

        normal = u'\x1B[0m'
        seq = u'\x1B[%sm' % code

        # Replace any normal sequences with this sequence to support nested colors
        return seq + (normal + seq).join(content.split(normal)) + normal
Apply a color code to text