def expandmarker(text, marker='', separator=''):
    """
    Return a marker expanded whitespace and the separator.

    It searches for the first occurrence of the marker and gets the combination
    of the separator and whitespace directly before it.

    @param text: the text which will be searched.
    @type text: str
    @param marker: the marker to be searched.
    @type marker: str
    @param separator: the separator string allowed before the marker. If empty
        it won't include whitespace too.
    @type separator: str
    @return: the marker with the separator and whitespace from the text in
        front of it. It'll be just the marker if the separator is empty.
    @rtype: str
    """
    if separator:
        firstinmarker = text.find(marker)
        firstinseparator = firstinmarker
        lenseparator = len(separator)
        striploopcontinue = True
        while firstinseparator > 0 and striploopcontinue:
            striploopcontinue = False
            if firstinseparator >= lenseparator and separator == text[
                firstinseparator - lenseparator:firstinseparator]:
                firstinseparator -= lenseparator
                striploopcontinue = True
            elif text[firstinseparator - 1] < ' ':
                firstinseparator -= 1
                striploopcontinue = True
        marker = text[firstinseparator:firstinmarker] + marker
    return marker
