Beispiel #1
0
def getMathMl(oleFormat, runForConversion=True):
	"""Get MathML from a MathType OLEFormat object.
	"""
	if runForConversion:
		oleFormat.DoVerb(2) # "RunForConversion"
	mt = oleFormat.object._comobj
	length = ctypes.c_long()
	# 2 is get MathML
	try:
		if lib.MTGetLangStrFromEqn(mt, 2, None, ctypes.byref(length)) != 0:
			raise RuntimeError
		mathMl = (ctypes.c_char * length.value)()
		if lib.MTGetLangStrFromEqn(mt, 2, ctypes.byref(mathMl), ctypes.byref(length)) != 0:
			raise RuntimeError
	finally:
		# 1 is OLECLOSE_NOSAVE
		lib.MTCloseOleObject(1, mt)
	return mathPres.stripExtraneousXml(mathMl.value)
Beispiel #2
0
def getMathMl(oleFormat, runForConversion=True):
    """Get MathML from a MathType OLEFormat object.
	"""
    if runForConversion:
        oleFormat.DoVerb(2)  # "RunForConversion"
    mt = oleFormat.object._comobj
    length = ctypes.c_long()
    # 2 is get MathML
    try:
        if lib.MTGetLangStrFromEqn(mt, 2, None, ctypes.byref(length)) != 0:
            raise RuntimeError
        mathMl = (ctypes.c_char * length.value)()
        if lib.MTGetLangStrFromEqn(mt, 2, ctypes.byref(mathMl),
                                   ctypes.byref(length)) != 0:
            raise RuntimeError
    finally:
        # 1 is OLECLOSE_NOSAVE
        lib.MTCloseOleObject(1, mt)
    return mathPres.stripExtraneousXml(mathMl.value)
Beispiel #3
0
 def _get_mathMl(self):
     import mathPres
     mathMl = mathPres.stripExtraneousXml(self.HTMLNode.outerHTML)
     if not mathPres.getLanguageFromMath(mathMl) and self.language:
         mathMl = mathPres.insertLanguageIntoMath(mathMl, self.language)
     return mathMl
	def _get_mathMl(self):
		import mathPres
		mathMl = mathPres.stripExtraneousXml(self.HTMLNode.outerHTML)
		if not mathPres.getLanguageFromMath(mathMl) and self.language:
			mathMl = mathPres.insertLanguageIntoMath(mathMl, self.language)
		return mathMl