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)])
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)])
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)
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)
def serialize(self, *args, **kwargs): return serialize_dom(self, *args, **kwargs)