def _fix_overlapping_graphics( spansStartingFrom ):
    ''' Provides a fix for overlapping annotations that are formatted graphically
        (underlined or printed in non-default color).
        
        If two graphically formatted annotations overlap, and if one annotation,
        say A, ends within another annotation, say B, then ending of graphics of A
        also causes graphics of B to end, and so, the end of A should restart the
        the graphics of B for a continuous visualisation;
        This method modifies ending tags in a way that annotations ending within
        other annotations will also contain restarts of the corresponding (super)-
        annotations, so that a continuous formatting is ensured.
    '''
    for startIndex in sorted( spansStartingFrom.keys() ):
        for span1 in spansStartingFrom[startIndex]:
            # If the span is not graphic, we don't have no worries - we can just skip it
            if not span1[5]:
               continue
            # Otherwise: check for other graphic spans that overlap with the given span
            span1Start = span1[0]
            span1End   = span1[1]
            for i in range( span1Start, span1End ):
                if i in spansStartingFrom:
                   for span2 in spansStartingFrom[i]:
                       span2Start = span2[0]
                       span2End   = span2[1]
                       # If the spans are not the same, and the span2 is graphic
                       if span2 != span1 and span2[5]:
                          # if the overlapping graphic span ends before the current span,
                          # we have to restart the graphic formatting of given span after 
                          # the end of the overlapping span
                          if span2End <= span1End:
                             if not span1[6]:
                                # If span1 is not bracketed, just add it at the end of
                                # the overlapping span
                                span2[4] += span1[3]
                             else:
                                # If span1 is bracketed, add it at the end of the 
                                # overlapping span without brackets
                                wb = span1[3].rstrip('[')
                                span2[4] += wb
Provides a fix for overlapping annotations that are formatted graphically
        (underlined or printed in non-default color).
        
        If two graphically formatted annotations overlap, and if one annotation,
        say A, ends within another annotation, say B, then ending of graphics of A
        also causes graphics of B to end, and so, the end of A should restart the
        the graphics of B for a continuous visualisation;
        This method modifies ending tags in a way that annotations ending within
        other annotations will also contain restarts of the corresponding (super)-
        annotations, so that a continuous formatting is ensured.