import itertools
import re


def text(soup):
    """Return main text for a given soup object."""
    if soup is None:
        return ''

    paragraphs = soup.find(attrs={"class": "mw-parser-output"}).find_all('p')
    all_text = ' '.join(list(itertools.chain.from_iterable(
        para.stripped_strings for para in paragraphs)))
    return re.sub('\[\d*\]', '', all_text)