

def chunkize(text, in_tag):
    start = 0
    idx = 0
    chunks = []
    for c in text:
        if (c == '<'):
            in_tag = True
            if (start != idx):
                chunks.append(('text', text[start:idx]))
            start = idx
        elif (c == '>'):
            in_tag = False
            if (start != (idx + 1)):
                chunks.append(('tag', text[start:(idx + 1)]))
            start = (idx + 1)
        idx += 1
    if (start != idx):
        chunks.append((('tag' if in_tag else 'text'), text[start:idx]))
    return (chunks, in_tag)

dataset/ETHPy150Open zulip/zulip/zerver/lib/html_diff.py chunkize/original