def xthebibliography(nd): r = txt.tr('References') p = spar('section') p.append(r) getap(nd).append(p) setx(nd, p, getap(nd)) ct.cnl(nd)
def xcaption(nd): p = getap(nd) s = nd.captionName.textContent + ' ' + nd.ref.textContent + ': ' r = txt.tr(s) p.append(r) setap(nd, p) ct.cnl(nd)
def xtheorem(nd): cap = nd.caption p = etree.Element(NSW + 'p') setap(cap, p) rbf.push() rbf.set() ct.cnl(cap) p.append(txt.tr(' ' + nd.ref.textContent)) rbf.pop() rif.push() rif.set() i = 1 if nd.childNodes[0].firstChild.nodeName == 'displaymath': i = 0 else: setap(nd.childNodes[0], p) ct.cnl(nd.childNodes[0]) np = getap(nd.parentNode) setap(nd, np) np.append(p) for par in nd.childNodes[i:]: ct.cnd(par) rif.pop() npf.clear()
def xabstract(nd): r = txt.tr('Abstract') p = spar('section') p.append(r) getap(nd).append(p) setx(nd, p, getap(nd)) ct.cnl(nd)
def xhspace(nd): s = nd.attributes['len'] n = int(s.em*6) t = txt.tr(u"\u2006"*n) getap(nd).append(t)
def xtheorem(nd): cap = nd.caption p = etree.Element(NSW+'p') setap(cap, p) rbf.push() rbf.set() ct.cnl(cap) p.append(txt.tr(' '+nd.ref.textContent)) rbf.pop() rif.push() rif.set() i = 1 if nd.childNodes[0].firstChild.nodeName == 'displaymath': i = 0 else: setap(nd.childNodes[0], p) ct.cnl(nd.childNodes[0]) np = getap(nd.parentNode) setap(nd, np) np.append(p) for par in nd.childNodes[i:]: ct.cnd(par) rif.pop() npf.clear()
def setbase(nd): p = getap(nd) if len(p)==0: x = txt.tr(u'\u200B') p.append(x) else: x = p[-1] n = nd.previousSibling.nodeName if n=='active::_' or n=='active::^': return x if n=='#text': t = x.find(NSM+'t') tt = t.text if len(tt)>1: tt1 = tt[-1] x1 = deepcopy(x) t1 = x1.find(NSM+'t') t1.text = tt1 t.text = tt[:-1] x = x1 else: p.remove(x) else: p.remove(x) if nd.nodeName == 'active::_': if nd.nextSibling == None: s = etree.Element(NSM+'sSub') e = etree.SubElement(s, NSM+'e') e.append(x) p.append(s) elif nd.nextSibling.nodeName != 'active::^': s = etree.Element(NSM+'sSub') e = etree.SubElement(s, NSM+'e') e.append(x) p.append(s) else: s = etree.Element(NSM+'sSubSup') e = etree.SubElement(s, NSM+'e') e.append(x) p.append(s) elif nd.nodeName == 'active::^': if nd.nextSibling==None: s = etree.Element(NSM+'sSup') e = etree.SubElement(s, NSM+'e') e.append(x) p.append(s) elif nd.nextSibling.nodeName != 'active::_': s = etree.Element(NSM+'sSup') e = etree.SubElement(s, NSM+'e') e.append(x) p.append(s) else: s = etree.Element(NSM+'sSubSup') e = etree.SubElement(s, NSM+'e') e.append(x) p.append(s) return s
def setbase(nd): p = getap(nd) if len(p) == 0: x = txt.tr(u'\u200B') p.append(x) else: x = p[-1] n = nd.previousSibling.nodeName if n == 'active::_' or n == 'active::^': return x if n == '#text': t = x.find(NSM + 't') tt = t.text if len(tt) > 1: tt1 = tt[-1] x1 = deepcopy(x) t1 = x1.find(NSM + 't') t1.text = tt1 t.text = tt[:-1] x = x1 else: p.remove(x) else: p.remove(x) if nd.nodeName == 'active::_': if nd.nextSibling == None: s = etree.Element(NSM + 'sSub') e = etree.SubElement(s, NSM + 'e') e.append(x) p.append(s) elif nd.nextSibling.nodeName != 'active::^': s = etree.Element(NSM + 'sSub') e = etree.SubElement(s, NSM + 'e') e.append(x) p.append(s) else: s = etree.Element(NSM + 'sSubSup') e = etree.SubElement(s, NSM + 'e') e.append(x) p.append(s) elif nd.nodeName == 'active::^': if nd.nextSibling == None: s = etree.Element(NSM + 'sSup') e = etree.SubElement(s, NSM + 'e') e.append(x) p.append(s) elif nd.nextSibling.nodeName != 'active::_': s = etree.Element(NSM + 'sSup') e = etree.SubElement(s, NSM + 'e') e.append(x) p.append(s) else: s = etree.Element(NSM + 'sSubSup') e = etree.SubElement(s, NSM + 'e') e.append(x) p.append(s) return s
def xsection(nd): s = nd.ref.textContent + '. ' + nd.attributes['title'].textContent r = txt.tr(s) p = spar('section') p.append(r) Body.append(p) setx(nd, p, Body) ct.cnl(nd)
def xArrayRow(nd): mr = etree.Element(NSM + 'mr') getap(nd).append(mr) setx(nd, mr, mr) ct.cnl(nd) if nd.parentNode.nodeName == 'eqnarray': e = etree.Element(NSM + 'e') mr.append(e) if nd.ref != None: ntf.push() ntf.set() e.append(txt.tr(' (' + nd.ref.textContent + ')')) ntf.pop()
def xArrayRow(nd): mr = etree.Element(NSM + "mr") getap(nd).append(mr) setx(nd, mr, mr) ct.cnl(nd) if nd.parentNode.nodeName == "eqnarray": e = etree.Element(NSM + "e") mr.append(e) if nd.ref != None: ntf.push() ntf.set() e.append(txt.tr(" (" + nd.ref.textContent + ")")) ntf.pop()
def xmaketitle(nd): i = 0 if 'title' in _mt.keys(): Body.insert(i,_mt['title']) i = i+1 if 'author' in _mt.keys(): Body.insert(i,_mt['author']) i = i+1 if 'date' in _mt.keys(): Body.insert(i,_mt['date']) else: npf.push() p = spar('author') p.append(txt.tr(datetime.date.strftime(datetime.date.today(),'%B %d, %Y'))) Body.insert(2, p) npf.pop()
def xmaketitle(nd): i = 0 if 'title' in _mt.keys(): Body.insert(i, _mt['title']) i = i + 1 if 'author' in _mt.keys(): Body.insert(i, _mt['author']) i = i + 1 if 'date' in _mt.keys(): Body.insert(i, _mt['date']) else: npf.push() p = spar('author') p.append( txt.tr(datetime.date.strftime(datetime.date.today(), '%B %d, %Y'))) Body.insert(2, p) npf.pop()
def xequation(nd): t = deepcopy(_tbe) it = t.iter(NSW + "p") lp = it.next() mp = it.next() rp = it.next() p = etree.SubElement(mp, NSM + "oMathPara") m = etree.SubElement(p, NSM + "oMath") ref = "(" + nd.ref.textContent + ")" rp.append(txt.tr(ref)) Body.append(t) setx(nd, p, m) mmf.push() mmf.set() ct.cnl(nd) mmf.pop()
def xequation(nd): t = deepcopy(_tbe) it = t.iter(NSW + 'p') lp = it.next() mp = it.next() rp = it.next() p = etree.SubElement(mp, NSM + 'oMathPara') m = etree.SubElement(p, NSM + 'oMath') ref = '(' + nd.ref.textContent + ')' rp.append(txt.tr(ref)) Body.append(t) setx(nd, p, m) mmf.push() mmf.set() ct.cnl(nd) mmf.pop()
def xstxt(nd): k = nd.nodeName v = _tum[k] getap(nd).append(txt.tr(v))
def xacchar(nd): getap(nd).append(txt.tr(nd.chars[nd.textContent]))
def xref(nd): getap(nd).append(txt.tr(nd.idref['label'].ref.textContent))
def xref(nd): getap(nd).append(txt.tr(nd.idref["label"].ref.textContent))
def xhspace(nd): s = nd.attributes['len'] n = int(s.em * 6) t = txt.tr(u"\u2006" * n) getap(nd).append(t)
def xbibitem(nd): p = etree.Element(NSW+'p') p.append(txt.tr('['+nd.bibcite.childNodes[0]+'] ')) setap(nd.firstChild, p) ct.cnl(nd.firstChild) getap(nd).append(p)
def xbibitem(nd): p = etree.Element(NSW + 'p') p.append(txt.tr('[' + nd.bibcite.childNodes[0] + '] ')) setap(nd.firstChild, p) ct.cnl(nd.firstChild) getap(nd).append(p)