def pprint_sequence(sequence, annotations=None, block_length=10,
                    blocks_per_line=6, format=PlaintextFormat):
    annotations = annotations or []
    partitioning = partition_range(len(sequence), annotations)
    margin = int(math.floor(math.log(max(len(sequence), 1), 10))
                 + 1) + len(format.margin[0])
    result = (format.margin[0] + '1').rjust(margin) + format.margin[1] + ' '
    for p in range(0, len(sequence), block_length):
        block = [(max(start, p), min(stop, p + block_length), levels)
                 for start, stop, levels in partitioning
                 if start < p + block_length and stop > p]
        result += ' '
        for start, stop, levels in block:
            delimiters = [(left, right) for level, (left, right)
                          in enumerate(format.annotations) if level in levels]
            result += (''.join(left for left, right in reversed(delimiters)) +
                       str(sequence[start:stop]) +
                       ''.join(right for left, right in delimiters))
        if (not (p + block_length) % (block_length * blocks_per_line) and
            p + block_length < len(sequence)):
            result += ('\n' + (format.margin[0] +
                               str(p + block_length + 1)).rjust(margin) +
                       format.margin[1] + ' ')
    return result