This commit is contained in:
Johann Dreo 2013-09-02 16:56:30 +02:00
commit f1bbd9eb16

View file

@ -492,6 +492,8 @@ def colorup(text, pattern, color="red", style="normal", on_groups=False):
# but that match.start(0) refers to the whole match, the groups being indexed in [1,n]. # but that match.start(0) refers to the whole match, the groups being indexed in [1,n].
# Thus, we need to range in [1,n+1[. # Thus, we need to range in [1,n+1[.
for group in range(1, nb_groups+1): for group in range(1, nb_groups+1):
# If a group didn't match, there's nothing to color
if match.group(group) is not None:
partial, end = colorout(text, match, end, group_colors[group-1], group_styles[group-1], group) partial, end = colorout(text, match, end, group_colors[group-1], group_styles[group-1], group)
colored_text += partial colored_text += partial