def merge_with_quotechar(S, dialect):
    """Merge quoted blocks in the abstraction

    This function takes the abstract representation and merges quoted blocks 
    (``QC...CQ``) to a single cell (``C``). The function takes nested quotes 
    into account.

    Parameters
    ----------
    S : str
        The data of a file as a string

    dialect : SimpleDialect
        The dialect used to make the abstraction.

    Returns
    -------
    abstraction : str
        A simplified version of the abstraction with quoted blocks merged.

    """
    in_quotes = False
    i = 0
    quote_pairs = []
    while i < len(S):
        s = S[i]
        if not s == 'Q':
            i += 1
            continue
        if not in_quotes:
            in_quotes = True
            begin_quotes = i
        elif i + 1 < len(S) and S[i + 1] == 'Q':
            i += 1
        else:
            end_quotes = i
            quote_pairs.append((begin_quotes, end_quotes))
            in_quotes = False
        i += 1
    Sl = list(S)
    for begin, end in quote_pairs:
        for i in range(begin, end + 1):
            Sl[i] = 'C'
    S = ''.join(Sl)
    return S
