Exemplo n.º 1
0
def dom_test(term, term_type, mathdom):
    doc = mathdom.fromString(term, term_type)
    infix  = serialize_dom(doc, 'infix')
    pyterm = serialize_dom(doc, 'python')

    return chain(pyeval( (term_type, term), (term_type.replace('python', 'infix'), infix) ),
                 [eval(pyterm)])
Exemplo n.º 2
0
def dom_test(term, term_type, mathdom):
    doc = mathdom.fromString(term, term_type)
    infix = serialize_dom(doc, 'infix')
    pyterm = serialize_dom(doc, 'python')

    return chain(
        pyeval((term_type, term),
               (term_type.replace('python', 'infix'), infix)), [eval(pyterm)])
Exemplo n.º 3
0
 def serialize(self, output_format=None, converter=None):
     "Serialize to 'mathml' (default) or any other supported term format."
     if converter is None:
         if output_format is None:
             output_format = 'mathml'
         if output_format == 'mathml':
             out = StringIO()
             Print(self._document, out)
             return out.getvalue()
         elif output_format == 'pmathml':
             raise ValueError, "Presentation MathML requires XSLT."
     return serialize_dom(self._document, output_format, converter)
Exemplo n.º 4
0
 def serialize(self, output_format=None, converter=None):
     "Serialize to 'mathml' (default) or any other supported term format."
     if converter is None:
         if output_format is None:
             output_format = 'mathml'
         if output_format == 'mathml':
             out = StringIO()
             Print(self._document, out)
             return out.getvalue()
         elif output_format == 'pmathml':
             raise ValueError, "Presentation MathML requires XSLT."
     return serialize_dom(self._document, output_format, converter)
Exemplo n.º 5
0
 def serialize(self, output_format=None, converter=None, **kwargs):
     """Serialize to 'mathml' (default), 'pmathml' or any other
     supported term format."""
     if converter is None:
         if output_format is None:
             output_format = 'mathml'
         if output_format == 'mathml':
             out = StringIO()
             self.toMathml(out, False)
             return out.getvalue()
         elif output_format in STYLESHEET_TRANSFORMERS:
             etree = self.xsltify(output_format, **kwargs)
             out = StringIO()
             etree.write(out, encoding='UTF-8')
             return out.getvalue()
     return serialize_dom(self._etree, output_format, converter)
Exemplo n.º 6
0
 def serialize(self, output_format=None, converter=None, **kwargs):
     """Serialize to 'mathml' (default), 'pmathml' or any other
     supported term format."""
     if converter is None:
         if output_format is None:
             output_format = 'mathml'
         if output_format == 'mathml':
             out = StringIO()
             self.toMathml(out, False)
             return out.getvalue()
         elif output_format in STYLESHEET_TRANSFORMERS:
             etree = self.xsltify(output_format, **kwargs)
             out = StringIO()
             etree.write(out, encoding='UTF-8')
             return out.getvalue()
     return serialize_dom(self._etree, output_format, converter)
Exemplo n.º 7
0
 def serialize(self, *args, **kwargs):
     return serialize_dom(self, *args, **kwargs)
Exemplo n.º 8
0
 def serialize(self, *args, **kwargs):
     return serialize_dom(self, *args, **kwargs)