diff bitsyblog/bitsyblog.py @ 75:6b8ccf6ec819

move restructured text string rendering to its own method
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 24 Sep 2010 19:01:07 -0700
parents c9bab68d00ac
children c690198a2625
line wrap: on
line diff
--- a/bitsyblog/bitsyblog.py	Thu Jul 08 11:13:08 2010 -0700
+++ b/bitsyblog/bitsyblog.py	Fri Sep 24 19:01:07 2010 -0700
@@ -10,7 +10,6 @@
 
 import dateutil.parser
 
-import cgi
 import datetime
 import docutils
 import docutils.core
@@ -654,21 +653,8 @@
         return buffer.getvalue()
                            
     def restructuredText(self, string):
-        """renders a string with restructured text"""
-
-        settings = { 'report_level': 5 }
-        string = string.strip()
-        try:
-            
-            parts = docutils.core.publish_parts(string,
-                                                writer_name='html',
-                                                settings_overrides=settings)
-            body = parts['body']
-        except (SystemMessage, UnicodeError), e:
-            lines = [ cgi.escape(i.strip()) for i in string.split('\n') ]
-            body = '<br/>\n'.join(lines)
-            
-
+        """renders a string with restructured text"""            
+        body = utils.ReST2html(string)
         retval = '<div class="blog-body">%s</div>' % body
         return retval