Created
May 3, 2022 20:22
-
-
Save data-goblin/6b944a251fe982c0aac3a803ed0734b5 to your computer and use it in GitHub Desktop.
Example of using pygments to format Python code with default configuration
This file contains 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
from pygments import highlight | |
from pygments.lexers import PythonLexer | |
from pygments.formatters import HtmlFormatter | |
code = """ | |
print('hello world') | |
""" | |
result = highlight(code, PythonLexer(), HtmlFormatter()) | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment