import re
from typing import OrderedDict


def get_example_sections(example):
    """Parses a multipart example and returns them in a dictionary by type.

    Types will be by language to highlight, except the special "__doc__"
    section. The default section is "html".
    """

    parts = re.split(r'<!-- (.*) -->', example)
    del parts[0]
    i = iter(parts)

    sections = OrderedDict()
    for lang, code in zip(i, i):
        sections[lang] = code.strip()
        # assert lang != 'TEMPLATE', example
    return sections