Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add display class for syntax-highlighted code #10978
Preparing some workshop materials, I've found myself wanting a better way to display a separate code file in a notebook.
There are many ways this could be extended - to add more output formats, or to let the user pick a pygments style, for instance. But I think what's there probably meets the 80% use case.
I did have another idea how to achieve this: send plain text with some metadata identifying the language, and let the frontend do the highlighting if it can: jupyter/nbconvert#363
That proposal is more elegant: it only sends the data once, it allows frontends to highlight in formats the kernel many not know about, and it works nicely for converting to formats like rst and markdown, which don't include highlighted code themselves, but may be rendered into a format which does.
However, this idea can be implemented in IPython and be useful immediately, whereas the other one requires changes to several different projects.