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

Support for pycon (python interactive snippets) #187

Open
mattharrison opened this issue Mar 15, 2024 · 4 comments
Open

Support for pycon (python interactive snippets) #187

mattharrison opened this issue Mar 15, 2024 · 4 comments

Comments

@mattharrison
Copy link

Lots of Python tooling uses doctests and interactive snippets to show code.

i.e:

>>> def add(x, y):
...    return x + y
>>> add(2, 3)
5

The benefit of this is multiple:

  • you can test the docs
  • you can see both the input and output
  • it is a standard that jupyter supports as well

Consider this my vote to add syntax highlighting for pycon like pygments does.

BTW, thanks for Pandoc. 🙏 It is a lifesaver. I've migrated most of my custom rst tooling to it. (Still can't use rst to create LibreOffice slides because none of the existing tooling has the features I need. But I digress). Thanks again!

@jgm
Copy link
Owner

jgm commented Mar 15, 2024

Using python instead of pycon as the syntax name seems to work well...have you tried that?

@mattharrison
Copy link
Author

I haven't because my LaTeX pipeline uses pygments to highlight the code and it does a poor job when you specify python instead of pycon

@jgm
Copy link
Owner

jgm commented Mar 15, 2024

For now you could use a Lua filter to substitute the pycon class with python in CodeBlock elements, when processing with pandoc.

@jgm
Copy link
Owner

jgm commented Mar 15, 2024

I looked at python.xml and I don't see any explicit support there for this interactive syntax. So it would be good, probably, to add a new pycon.xml. This can "call out" to the highlighter defined in python.xml, so it might be quite simple to design. There are pointers to the documentation in the README.md for this project.

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

2 participants