str2tex done and integrate into MO

This commit is contained in:
2018-03-10 16:08:28 +03:00
parent d14850c78d
commit b2239e0e56
3 changed files with 241 additions and 1 deletions

View File

@@ -7,7 +7,7 @@
# Distributed under terms of the MIT license.
from ..coroutine import coroutine, STOOOP
from ..renders import tree2txt
from ..renders import tree2txt, tree2tex
from decimal import Decimal
@@ -91,6 +91,13 @@ class MO(object):
except AttributeError:
return str(self.value)
@property
def __tex__(self):
try:
return tree2tex(self.value)
except AttributeError:
return str(self.value)
def __add__(self, other):
""" Overload + for MOs
@@ -195,6 +202,12 @@ class MOnumber(MO):
return f"- {abs(self.value)}"
@property
def __tex__(self):
if self.value > 0:
return str(self.value)
return f"- {abs(self.value)}"
class MOstr(MO):