def annotation_to_inline(text,
                         markup,
                         wrappers,
                         wrappers_dict={}):
    """
        Applies all annotations to the text.

        There are two types of annotations:
        markup - markup tags that need to be applied to the text.
        wrappers - This identifies pieces of text that should be wrapped
        with some code. For instance glossaries.

        wrappers_dict:
            Func to apply to each wrapper. The dictionary is indexed
            by the wrapper type.
    """

    if markup:
        # add markup
        intervals_tagged_text = get_list_to_insert_tags(text, markup)
    else:
        intervals_tagged_text = [[text, False]]
    tagged_intervals = []
    start = 0
    end = 0
    spaces_added = 0
    for interval, added_space in intervals_tagged_text:
        if count_tags_in_string(interval) == 0:
            end = start + len(interval)
            if added_space:
                spaces_added += 1
            new_text = add_annotataions_part(
                interval,
                wrappers,
                start,
                end,
                wrappers_dict)
            start = end + spaces_added
            tagged_intervals.append(new_text)
        else:
            tagged_intervals.append(interval)
    tagged_text = "".join(tagged_intervals)
    return tagged_text