I've been trying to get syntax highlighting working in my simple Django (1.1) test app using Markdown (2.0.1) & Pygments (1.0). The idea is to generate HTML from the users input which is in markdown format and store both in the DB so I don't have to do the markdown to html translation during the fetch.
So far I have the markdown processing working but I cannot seem to get syntax highlighting working. My models.py looks like this:
from django.db import models
from django.contrib import admin
from markdown import markdown
class BlogPost( models.Model ):
title = models.CharField( max_length = 150 )
body = models.TextField()
body_html = models.TextField(editable=False, blank=True, null=True)
timestamp = models.DateTimeField()
def save(self):
self.body_html = markdown(self.body, ['codehilite'])
super( BlogPost, self).save()
class Meta:
ordering = ( '-timestamp', )
class BlogPostAdmin( admin.ModelAdmin ):
list_display = ( 'title', 'timestamp' )
admin.site.register(BlogPost, BlogPostAdmin)
So far testing just markdown syntax works but if I try something like the following I don't seen any syntax highlighting in the output or the output source:
:::python
from foo import bar
foobar = bar('foo')
I'd expect to see at least a set of code elements in the output source.