Mercurial > hg > bitsyblog
changeset 76:c690198a2625
merge commit
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 26 Sep 2010 10:38:51 -0700 |
parents | 6b8ccf6ec819 (diff) 2c219b788648 (current diff) |
children | 5b1259424c51 |
files | bitsyblog/bitsyblog.py |
diffstat | 2 files changed, 19 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- 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 = '<br/>\n'.join(lines) - - + """renders a string with restructured text""" + body = utils.ReST2html(string) retval = '<div class="blog-body">%s</div>' % body return retval
--- 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 = '<br/>\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'