def rst_to_html(in_rst, stderr):
 if (not in_rst):
  return (u'', 0)
 orig_sys_exit = sys.exit
 orig_sys_stderr = sys.stderr
 returncodes = []
 try:
  sys.exit = returncodes.append
  sys.stderr = stderr
  pp = publish_parts(in_rst, writer_name=u'html', settings_overrides=dict(exit_status_level=2, report_level=2), enable_exit_status=True)
 finally:
  sys.exit = orig_sys_exit
  sys.stderr = orig_sys_stderr
 return_value = u''
 if ((u'title' in pp) and pp[u'title']):
  return_value += u'<title>{0}</title>\n<p style="font: 200% bold">{0}</p>\n'.format(pp[u'title'])
 return_value += pp[u'body'].strip()
 return (return_value, (returncodes.pop() if returncodes else 0))

def rst_to_html ( in_rst , stderr ) : if ( not in_rst ) : return ( u'' , 0 ) orig_sys_exit = sys . exit orig_sys_stderr = sys . stderr returncodes = [ ] try : sys . exit = returncodes . append sys . stderr = stderr pp = publish_parts ( in_rst , writer_name = u'html' , settings_overrides = dict ( exit_status_level = 2 , report_level = 2 ) , enable_exit_status = True ) finally : sys . exit = orig_sys_exit sys . stderr = orig_sys_stderr return_value = u'' if ( ( u'title' in pp ) and pp [ u'title' ] ) : return_value += u'<title>{0}</title>\n<p style="font: 200% bold">{0}</p>\n' . format ( pp [ u'title' ] ) return_value += pp [ u'body' ] . strip ( ) return ( return_value , ( returncodes . pop ( ) if returncodes else 0 ) )
renders html from an rst fragment .