from django.contrib.auth.models import User
from django.contrib.auth.models import AnonymousUser
from datetime import datetime
+from genshi import Markup
import re
def highlight(text, phrase,
return self.course.course_url()
#------------------------------------------------------------
+# News items
+
+try:
+ import markdown
+ def do_markdown(txt):
+ return markdown.markdown(txt)
+except ImportError:
+ def do_markdown(txt):
+ return '(Markdown not installed).'
class NewsItem(m.Model):
subject = m.CharField(max_length=200)
('html', 'html'),
('markdown', 'markdown')),
default = 'html')
+
+ def generated_body(self):
+ if self.encoding == 'plain':
+ return self.body
+ elif self.encoding == 'html':
+ return Markup(self.body)
+ elif self.encoding == 'markdown':
+ return Markup(do_markdown(self.body))
+