def html_highlight(classified_text, opener='<pre class="python">\n', closer='</pre>\n'):
 result = [opener]
 for (kind, text) in classified_text:
  if kind:
   result.append(('<span class="%s">' % kind))
  result.append(cgi.escape(text))
  if kind:
   result.append('</span>')
 result.append(closer)
 return ''.join(result)

def html_highlight ( classified_text , opener = '<pre class="python">\n' , closer = '</pre>\n' ) : result = [ opener ] for ( kind , text ) in classified_text : if kind : result . append ( ( '<span class="%s">' % kind ) ) result . append ( cgi . escape ( text ) ) if kind : result . append ( '</span>' ) result . append ( closer ) return '' . join ( result )
convert classified text to an html fragment .