| Download
Process FriCAS output using Markdown.
Project: Many Interacting Worlds
Path: fricas_md.py
Views: 97def fricas_md(s):1import re2t = fricas._eval_line_using_file(s, restart_if_needed=False, reformat=False)3# cleanup plain text4t=re.compile(r'\r\r').sub('\r',t,count=0)5t=re.compile(r'\r').sub('\n',t,count=0)6t=re.compile(r' ').sub('',t,count=0)7t=re.compile(r' ').sub(' ',t,count=0)8#t=re.compile(r' Compiling').sub('Compiling',t)9# fix mathml overbar10t=re.compile(r'¯').sub('‾',t,count=0)11# cleanup FriCAS LaTeX12t=re.compile(r'\\leqno\(.*\)\n').sub('',t)13t=re.compile(r'\\sb ').sub('_',t,count=0)14t=re.compile(r'\\sp ').sub('^',t,count=0)15t=re.compile(r'\\erf ').sub(r'\\mathrm{erf}',t,count=0)16t=re.compile(r'\\sech ').sub(r'\\mathrm{sech}',t,count=0)17t=re.compile(r'\\tanh ').sub(r'\\mathrm{tanh}',t,count=0)18# float result type to the right19t=re.compile(r' *Type: (.*)\n').sub(r'<p style="text-align:right">Type: \1</p>\n',t,count=0)20#print t21md(t, hide=False)2223