def to_latex(expr):
 if (expr is None):
  return ''
 expr_s = latex(expr)
 expr_s = expr_s.replace('\\XI', 'XI')
 expr_s = re.sub('script([a-zA-Z0-9]+)', '\\mathcal{\\1}', expr_s)
 if (expr_s[0] == '$'):
  return ('[mathjax]%s[/mathjax]<br>' % expr_s[1:(-1)])
 return ('[mathjax]%s[/mathjax]<br>' % expr_s)

def to_latex ( expr ) : if ( expr is None ) : return '' expr_s = latex ( expr ) expr_s = expr_s . replace ( '\\XI' , 'XI' ) expr_s = re . sub ( 'script([a-zA-Z0-9]+)' , '\\mathcal{\\1}' , expr_s ) if ( expr_s [ 0 ] == '$' ) : return ( '[mathjax]%s[/mathjax]<br>' % expr_s [ 1 : ( - 1 ) ] ) return ( '[mathjax]%s[/mathjax]<br>' % expr_s )
convert expression to latex mathjax format .