Python Syntax Highlighter

Version 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.

Cut and paste code here:



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)
    


Subscribe RSS Feed Bookmark and Share

More Blog Entries

Ed Menendez' Facebook profile