Checks all elements and creates a list of diferent markers for styles or different elements.

def mark_styles(ctx, doc, elements):
    """
    Checks all elements and creates a list of diferent markers for styles or different elements.
    """

    not_using_styles = False

    if ctx.options['not_using_styles']:
        if len(doc.used_styles) < ctx.options['minimum_used_styles'] and len(doc.possible_headers) < ctx.options['minimum_possible_headers']:
            not_using_styles = True
            doc.possible_headers = [POSSIBLE_HEADER_SIZE] + doc.possible_headers

            logger.info('   => not using styles')

    markers = [{'name': '', 'weight': 0, 'index': 0, 'font_size': 0}]

    for pos, elem in enumerate(elements):
        try:
            style = doc.styles.get_by_id(elem.style_id)
        except AttributeError:
            style = None

        if isinstance(elem, Paragraph):
            # Ignore if it is dropcap. 
            # What we should do here is also calculate weight, which we do not do at the moment.
            if elem.is_dropcap():
                continue

            for el in elem.elements:
                # insert it inside
                if isinstance(el, Break):
                    markers.append({'name': '', 'weight': 0, 'index': pos, 'font_size': 0, 'page_break': True})

        weight = calculate_weight(doc, elem)
        if weight == 0:
            continue

        font_size = -1
        has_found = False

        if isinstance(elem, TOC):
            markers.append({'name': '', 'weight': weight, 'index': pos, 'font_size': fnt_size, 'is_toc': True})
            continue                

        if style:
            markers.append({'name': elem.style_id, 'weight': weight, 'index': pos})
            if elem.style_id == 'ContentsHeading':
                markers[-1]['is_toc'] = True

            has_found = True
        else:
            if ctx.options['header_as_text']:
                if hasattr(elem, 'rpr') and 'sz' in elem.rpr:

                    t_length = text_length(elem)

                    if  t_length < ctx.options['header_as_text_length'] and t_length >= ctx.options['header_as_text_length_minimum']:
                        markers.append({'name': '', 'weight': weight, 'index': pos, 'font_size': int(elem.rpr['sz']) / 2})
                        font_size = int(elem.rpr['sz'])/2
                        has_found = True

            if ctx.options['header_as_bold_centered']:
                if not_using_styles:
                    if hasattr(elem, 'rpr') and ('jc' in elem.ppr or 'b' in elem.rpr or 'i' in elem.rpr):
                        if text_length(elem) < 30:

                            elements[pos].possible_header = True

                            markers.append({'name': '', 'weight': weight+100, 'index': pos, 'font_size': POSSIBLE_HEADER_SIZE})
                            font_size = POSSIBLE_HEADER_SIZE
                            has_found = True

        if ctx.options['header_as_text_in_elements']:
            if hasattr(elem, 'elements'):
                for e in elem.elements:
                    # TODO
                    # check if this is empty element
                    if hasattr(e, 'rpr') and 'sz' in e.rpr:
                        t_length = text_length(elem)
                        if  t_length < ctx.options['header_as_text_length'] and t_length >= ctx.options['header_as_text_length_minimum']: 
                            fnt_size = int(e.rpr['sz'])/2

                            if fnt_size != font_size:
                                markers.append({'name': '', 'weight': weight, 'index': pos, 'font_size': fnt_size})
                                has_found = True

        if not has_found and len(markers) > 0:
            markers[-1]['weight'] += weight

    return markers