def METHOD_NAME(listing):
    text = fix_newlines(listing.text_content().strip())
    commands = listing.cssselect('pre strong')
    if not commands:
        return [Output(text)]
    outputs = []
    output_before = listing.text
    if output_before:
        output_before = fix_newlines(output_before.strip())
    else:
        output_before = ''
    for command in commands:
        if '$' in output_before and '\n' in output_before:
            last_cr = output_before.rfind('\n')
            previous_lines = output_before[:last_cr]
            if previous_lines:
                outputs.append(Output(previous_lines))
        elif output_before and '$' not in output_before:
            outputs.append(Output(output_before))
        command_text = fix_newlines(command.text)
        if output_before.strip().startswith('(virtualenv)'):
            command_text = 'source ./.venv/bin/activate && ' + command_text
        outputs.append(Command(command_text))
        output_before = fix_newlines(command.tail)
    if output_before:
        outputs.append(Output(output_before))
    return outputs