Created
February 18, 2017 04:21
-
-
Save garywu/90cb3ce62e611b021060e464fd58cb47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cheap immitation of %pycat | |
from IPython.core.display import display, HTML | |
from pygments import highlight | |
from pygments.lexers import PythonLexer | |
from pygments.formatters import HtmlFormatter | |
def show(filename): | |
text = !cat $filename | |
text = '\n'.join(text) | |
html = highlight(text, PythonLexer(), HtmlFormatter()) | |
display(HTML(html)) | |
display(HTML(""" | |
<style> | |
{pygments_css} | |
</style> | |
""".format(pygments_css=HtmlFormatter().get_style_defs('.highlight')))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment