def cell_content(cell):
    """Return cell's content ready to be used in SPARQL requests.
    """

    # Remove references
    for sup in cell.findAll('sup'):
        sup.decompose()

    # Remove breaks
    for br in cell.findAll('br'):
        br.decompose()

    # Try find a
    a = cell.find('a', href=True)
    if not a:
        literal = cell.text.strip('\n \"')
        literal = ' '.join(literal.split())
        literal = literal.replace('\\', '\\\\')
        literal = literal.replace('"', '\\"')
        return literal
    else:
        # Handle red links
        if a.has_attr('class') and 'new' in a['class']:
            return a.text

        return a['href'].replace('/wiki', 'http://dbpedia.org/resource')