Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suport for interactive Python shell code? #77

Open
liqimai opened this issue Mar 29, 2022 · 2 comments
Open

Suport for interactive Python shell code? #77

liqimai opened this issue Mar 29, 2022 · 2 comments

Comments

@liqimai
Copy link

liqimai commented Mar 29, 2022

It is quite often markdown contains interactive Python shell code like:

>>> print("Hello World!")
Hello World!
>>> def add(a, b):
...     return a + b
...
>>> add(2,3)
5

Currently, I got following exception for these blocks in my README.md.

invalid syntax (<string>, line 1)

Can you add support to test it? I expect the behaviour to be same as pytest --doctest-modules, as if the code block is a function's doc-string.

@nschloe
Copy link
Owner

nschloe commented Mar 29, 2022

Interesting idea! I don't have any spare time to devote to this right now, but you can either submit a PR or sponsor me so I can move this into my working hours.

@antonagestam
Copy link

I came here looking for this too, I just thought it worth mentioning that Github supports syntax highlighting of interactive codeblocks with a different code than normal Python, pycon, e.g.:

```pycon
 >>> "Hello " + "stranger"
 'Hello stranger'
```

Renders as:

>>> "Hello " + "stranger"
'Hello stranger'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants