Executes a code block by passing it to the executor.

    Args:
        elem The AST element.
        doc  The document.

    Returns:
        The output of the command.

def execute_code_block(elem, doc):
    """Executes a code block by passing it to the executor.

    Args:
        elem The AST element.
        doc  The document.

    Returns:
        The output of the command.
    """
    command = select_executor(elem, doc).split(' ')
    code = elem.text
    if 'plt' in elem.attributes or 'plt' in elem.classes:
        code = save_plot(code, elem)
    command.append(code)
    if 'args' in elem.attributes:
        for arg in elem.attributes['args'].split():
            command.append(arg)

    cwd = elem.attributes['wd'] if 'wd' in elem.attributes else None

    return subprocess.run(command,
                          encoding='utf8',
                          stdout=subprocess.PIPE,
                          stderr=subprocess.STDOUT,
                          cwd=cwd).stdout