From: Leandro Lucarella Date: Tue, 5 Aug 2008 00:04:46 +0000 (-0300) Subject: Move docutils rendering bits to a helper function X-Git-Url: https://git.llucax.com/software/blitiri.git/commitdiff_plain/5e9ec03d1df2e0b034c65f3f67b5064d8f434178 Move docutils rendering bits to a helper function --- diff --git a/blitiri.cgi b/blitiri.cgi index 0992fd2..eea49b5 100755 --- a/blitiri.cgi +++ b/blitiri.cgi @@ -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

" 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 {