]> git.llucax.com Git - software/blitiri.git/commitdiff
Move docutils rendering bits to a helper function
authorLeandro Lucarella <llucax@gmail.com>
Tue, 5 Aug 2008 00:04:46 +0000 (21:04 -0300)
committerAlberto Bertogli <albertito@blitiri.com.ar>
Fri, 8 Aug 2008 22:53:20 +0000 (19:53 -0300)
blitiri.cgi

index 0992fd2f1f7a25ec14213b71dfcadc28415cb9fd..eea49b512feff527fadebfc3f6efbbd9484866a1 100755 (executable)
@@ -202,6 +202,16 @@ div.section h1 {
 
 """
 
+# helper function
+def rst_to_html(rst):
+       settings = {
+               'input_encoding': encoding,
+               'output_encoding': 'utf8',
+       }
+       parts = publish_parts(rst, settings_overrides = settings,
+                               writer_name = "html")
+       return parts['body'].encode('utf8')
+
 # find out our URL, needed for syndication
 try:
        n = os.environ['SERVER_NAME']
@@ -350,14 +360,7 @@ class Article (object):
                        return "Can't open post file<p>"
                raw = raw[raw.index('\n'):]
 
-               settings = {
-                       'input_encoding': encoding,
-                       'output_encoding': 'utf8',
-               }
-               parts = publish_parts(self.raw_content,
-                               settings_overrides = settings,
-                               writer_name = "html")
-               return parts['body'].encode('utf8')
+               return rst_to_html(self.raw_content)
 
        def to_vars(self):
                return {