# HG changeset patch # User Jeff Hammel # Date 1285522731 25200 # Node ID c690198a2625659180ff70066f6dafc7dfcda95b # Parent 6b8ccf6ec8198ab7a656f252a466731c9369eb7c# Parent 2c219b7886484d926af9dca5aae635a684148705 merge commit diff -r 2c219b788648 -r c690198a2625 bitsyblog/bitsyblog.py --- a/bitsyblog/bitsyblog.py Wed Sep 15 10:34:14 2010 -0700 +++ b/bitsyblog/bitsyblog.py Sun Sep 26 10:38:51 2010 -0700 @@ -10,7 +10,6 @@ import dateutil.parser -import cgi import datetime import docutils import docutils.core @@ -657,21 +656,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 = '
\n'.join(lines) - - + """renders a string with restructured text""" + body = utils.ReST2html(string) retval = '
%s
' % body return retval diff -r 2c219b788648 -r c690198a2625 bitsyblog/utils.py --- a/bitsyblog/utils.py Wed Sep 15 10:34:14 2010 -0700 +++ b/bitsyblog/utils.py Sun Sep 26 10:38:51 2010 -0700 @@ -1,5 +1,6 @@ """utlity functions for bitsyblog""" +import cgi import datetime import os import urllib @@ -9,6 +10,22 @@ timeformat = ( 'YYYY', 'MM', 'DD', 'HH', 'MM', 'SS' ) timestamp = '%Y%m%d%H%M%S' # strftime representation +def ReST2html(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 = '
\n'.join(lines) + return body + def validate_css(css): """use a webservice to determine if the argument is valid css""" url = 'http://jigsaw.w3.org/css-validator/validator?text=%s'