pawamoy / markdown-exec

Utilities to execute code blocks in Markdown files.
https://pawamoy.github.io/markdown-exec
ISC License
111 stars 8 forks source link

Allow integrating output in the source itself #3

Closed pawamoy closed 2 years ago

pawamoy commented 2 years ago

Is your feature request related to a problem? Please describe. Following #1 and #2, it would be nice if we could integrate the output of Python code directly within the source itself, most commonly at the end.

Describe the solution you'd like An integrated-above (or concat?) option for the show_source configuration. Basically: output = code_block("python", source_block + "\n" + output).

It would allow this:

def func(name):
    """Return "hello" plus name.

    Example:
        ```pycon exec="yes" show_source="integrated-above" capture="out"
        >>> from module import func
        >>> print(func("Steve"))
"""
return f"Hello {name}!"

Result:

```pycon
>>> from module import func
>>> print(func("Steve"))
Hello Steve!