Esempio n. 1
0
    def process_children(self, elm, include=None):
        """
		process children of the elm,return string
		"""
        return BLANK.join(
            (t if not isinstance(t, Tag2Method) else str(t)
             for stag, t, e in self.process_children_list(elm, include)))
Esempio n. 2
0
def escape_latex(strs):
	last = None
	new_chr = []
	for c in strs :
		if (c in CHARS) and (last !=BACKSLASH):
			new_chr.append(BACKSLASH+c)
		else:
			new_chr.append(c)
		last = c
	return BLANK.join(new_chr)
Esempio n. 3
0
    def do_r(self, elm):
        """
		Get text from 'r' element,And try convert them to latex symbols
		@todo text style support , (sty)
		@todo \text (latex pure text support)
		"""
        _str = []
        for s in elm.findtext('./{0}t'.format(OMML_NS)):
            #s = s if isinstance(s,unicode) else unicode(s,'utf-8')
            _str.append(self._t_dict.get(s, s))
        return escape_latex(BLANK.join(_str))
Esempio n. 4
0
	def do_r(self,elm):
		"""
		Get text from 'r' element,And try convert them to latex symbols
		@todo text style support , (sty)
		@todo \text (latex pure text support)
		"""
		_str = []
		for s in elm.findtext('./{0}t'.format(OMML_NS)):
			#s = s if isinstance(s,unicode) else unicode(s,'utf-8')
			_str.append(self._t_dict.get(s,s))
		return escape_latex(BLANK.join(_str))
Esempio n. 5
0
    def do_nary(self, elm):
        """
		the n-ary object
		"""
        res = []
        bo = ''
        for stag, t, e in self.process_children_list(elm):
            if stag == 'naryPr':
                bo = get_val(t.chr, store=CHR_BO)
            else:
                res.append(t)
        return bo + BLANK.join(res)
Esempio n. 6
0
	def do_nary(self,elm):
		"""
		the n-ary object
		"""
		res = []
		bo = ''
		for stag,t,e in self.process_children_list(elm):
			if stag == 'naryPr':
				bo = get_val(t.chr,store=CHR_BO)
			else :
				res.append(t)
		return bo+BLANK.join(res)
Esempio n. 7
0
    def do_fname(self, elm):
        """
		the func name
		"""
        latex_chars = []
        for stag, t, e in self.process_children_list(elm):
            if stag == 'r':
                if FUNC.get(t):
                    latex_chars.append(FUNC[t])
                else:
                    raise NotSupport("Not support func %s" % t)
            else:
                latex_chars.append(t)
        t = BLANK.join(latex_chars)
        return t if FUNC_PLACE in t else t + FUNC_PLACE  #do_func will replace this
Esempio n. 8
0
	def do_fname(self,elm):
		"""
		the func name
		"""
		latex_chars = []
		for stag,t,e in self.process_children_list(elm):
			if stag == 'r':
				if FUNC.get(t):
					latex_chars.append(FUNC[t])
				else :
					raise NotSupport("Not support func %s" % t)
			else:
				latex_chars.append(t)
		t = BLANK.join(latex_chars)
		return t if FUNC_PLACE in t else t+FUNC_PLACE #do_func will replace this
Esempio n. 9
0
	def process_children(self,elm,include=None):
		"""
		process children of the elm,return string
		"""
		return BLANK.join(( t if not isinstance(t,Tag2Method) else str(t) 
			for stag,t,e in self.process_children_list(elm,include)))