str2tex done and integrate into MO
This commit is contained in:
@@ -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):
|
||||
|
||||
|
Reference in New Issue
Block a user