def before_after_text(join_set, index, interval_list):
    """
    Extracts any preceeding or following markup to be joined to an interval's text.
    """

    before_text, after_text = '', ''

    # Checking if we have some preceeding or following markup to join with.

    if join_set:

        if index > 0:

            before_text = ''.join(character
                for character in interval_list[index - 1][2]
                if character in join_set)

        if index < len(interval_list) - 1:

            after_text = ''.join(character
                for character in interval_list[index + 1][2]
                if character in join_set)

    return before_text, after_text