|
|
Python Syntax HighlighterVersion 1.0 Simply paste your code. Click "color me" and copy and paste the output. If you use this often you may want to include the styles in your style sheet. Here's the code to do this from pygments import highlight
from pygments.lexers import PythonLexer
from pygments.formatters import HtmlFormatter
import os
formatter = HtmlFormatter()
context['formatter'] = formatter.get_style_defs('.highlight')
code = request.POST['code']
context['html'] = highlight(code, PythonLexer(), formatter)
|
More Blog Entries
|