def render_to_html(eq):
 def err(s):
  'Render as an error span'
  return '<span class="inline-error inline">{0}</span>'.format(s)
 def render_arrow(arrow):
  'Turn text arrows into pretty ones'
  if (arrow == '->'):
   return u'\u2192'
  if (arrow == '<->'):
   return u'\u2194'
  return arrow
 def render_expression(ex):
  '\n        Render a chemical expression--no arrows.\n        '
  try:
   return _render_to_html(_get_final_tree(ex))
  except ParseException:
   return err(ex)
 def spanify(s):
  return u'<span class="math">{0}</span>'.format(s)
 (left, arrow, right) = split_on_arrow(eq)
 if (arrow == ''):
  return spanify(render_expression(left))
 return spanify(((render_expression(left) + render_arrow(arrow)) + render_expression(right)))

def render_to_html ( eq ) : def err ( s ) : return '<span class="inline-error inline">{0}</span>' . format ( s ) def render_arrow ( arrow ) : if ( arrow == '->' ) : return u'\u2192' if ( arrow == '<->' ) : return u'\u2194' return arrow def render_expression ( ex ) : try : return _render_to_html ( _get_final_tree ( ex ) ) except ParseException : return err ( ex ) def spanify ( s ) : return u'<span class="math">{0}</span>' . format ( s ) ( left , arrow , right ) = split_on_arrow ( eq ) if ( arrow == '' ) : return spanify ( render_expression ( left ) ) return spanify ( ( ( render_expression ( left ) + render_arrow ( arrow ) ) + render_expression ( right ) ) )
render a chemical equation string to html .