Coverage for local/lib/python2.7/site-packages/sage/misc/mathml.py : 31%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" MathML output support
In order to support MathML formatting, an object should define a special method _mathml_(self) that returns its MathML representation. """
#***************************************************************************** # # Sage: System for Algebra and Geometry Experimentation # # Copyright (C) 2005 William Stein <wstein@gmail.com> # # Distributed under the terms of the GNU General Public License (GPL) # # This code is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # The full text of the GPL is available at: # # http://www.gnu.org/licenses/ #***************************************************************************** from __future__ import absolute_import from six import iteritems, integer_types
def list_function(x): return 'MATHML version of the list %s' % (x,)
def tuple_function(x): return 'MATHML version of the tuple %s' % (x,)
def bool_function(x): return 'MATHML version of %s' % (x,)
def str_function(x):
# One can add to the latex_table in order to install latexing # functionality for other types.
mathml_table = {list: list_function, tuple:tuple_function, bool:bool_function, str: str_function, float:str} for x in integer_types: mathml_table[x] = str
class MathML(str): def __repr__(self):
def mathml(x): """ Output x formatted for inclusion in a MathML document. """
if x is None: return MathML("MATHML version of 'None'")
return MathML(str_function(str(x)))
|