<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def wc(filename, contents, parsed=None, is_jekyll=False):
 """Count the words, characters, and paragraphs in a string. Args: contents: the original string to count filename (optional):
 the filename as provided to the CLI parsed (optional):
 a parsed string, expected to be plaintext only is_jekyll: whether the original contents were from a Jekyll file Returns: An object containing the various counts """

    if is_jekyll:
        fmt = 'jekyll'
    else:
        fmt = 'md/txt'
    body = parsed.strip() if parsed else contents.strip()

    # Strip the body down to just words
    words = re.sub(r'\s+', ' ', body, re.MULTILINE)
    for punctuation in INTERSTITIAL_PUNCTUATION:
        words = re.sub(punctuation, ' ', words)
    punct = re.compile('[^\w\s]', re.U)
    words = punct.sub('', words)

    # Retrieve only non-space characters
    real_characters = re.sub(r'\s', '', words)

    # Count paragraphs in an intelligent way
    paragraphs = [1 if len(x) == 0 else 0 for x in
                  contents.strip().splitlines()]
    for index, paragraph in enumerate(paragraphs):
        if paragraph == 1 and paragraphs[index + 1] == 1:
            paragraphs[index] = 0

    return {
        'counts': {
            'file': filename,
            'type': fmt,
            'paragraphs': sum(paragraphs) + 1,
            'words': len(re.split('\s+', words)),
            'characters_real': len(real_characters),
            'characters_total': len(words),
        }
    }