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 xtitle(nd): npf.push() p = spar('title') _mt['title'] = p setx(nd, p, p) ct.cnl(nd) npf.pop()
def xauthor(nd): npf.push() p = spar('author') _mt['author'] = p setx(nd, p, p) ct.cnl(nd) npf.pop()
def xdate(nd): npf.push() p = spar('author') _mt['date'] = p setx(nd, p, p) ct.cnl(nd) npf.pop()
def xpar(nd): if nd.childNodes: if nd.firstChild.nodeName in { 'enumerate', 'itemize', 'equation', 'abstract', 'thebibliography', 'table', 'centering', 'tabular', 'center' }: setap(nd, getap(nd)) ct.cnl(nd) return else: return if mmf.isset(): setap(nd, getap(nd)) ct.cnl(nd) return if nd.parentNode.nodeName == 'item': enum.itempar(nd) return p = etree.Element(NSW + 'p') setAlign(p) setx(nd, p, p) npf.clear() ct.cnl(nd) if npf.isset(): getap(nd).append(p)
def xpar(nd): if nd.childNodes: if nd.firstChild.nodeName in {'enumerate', 'itemize', 'equation', 'abstract', 'thebibliography', 'table', 'centering', 'tabular', 'center'}: setap(nd, getap(nd)) ct.cnl(nd) return else: return if mmf.isset(): setap(nd, getap(nd)) ct.cnl(nd) return if nd.parentNode.nodeName=='item': enum.itempar(nd) return p = etree.Element(NSW+'p') setAlign(p) setx(nd, p, p) npf.clear() ct.cnl(nd) if npf.isset(): getap(nd).append(p)
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 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 xsup(nd): ss = setbase(nd) if ss is None: return s = etree.Element(NSM + 'sup') setx(nd, s, s) ct.cnl(nd) ss.append(s)
def xsup(nd): ss = setbase(nd) if ss is None: return s = etree.Element(NSM+'sup') setx(nd, s, s) ct.cnl(nd) ss.append(s)
def accent(nd, char): a = etree.Element(NSM + "acc") pr = etree.SubElement(a, NSM + "accPr") ch = etree.SubElement(pr, NSM + "chr") ch.set(NSM + "val", char) e = etree.SubElement(a, NSM + "e") getap(nd).append(a) setx(nd, a, e) ct.cnl(nd)
def accent(nd, char): a = etree.Element(NSM + 'acc') pr = etree.SubElement(a, NSM + 'accPr') ch = etree.SubElement(pr, NSM + 'chr') ch.set(NSM + 'val', char) e = etree.SubElement(a, NSM + 'e') getap(nd).append(a) setx(nd, a, e) ct.cnl(nd)
def xbar(nd): a = etree.Element(NSM + 'acc') pr = etree.SubElement(a, NSM + 'accPr') ch = etree.SubElement(pr, NSM + 'chr') ch.set(NSM + 'val', u'\u0304') e = etree.SubElement(a, NSM + 'e') getap(nd).append(a) setx(nd, a, e) ct.cnl(nd)
def xbar(nd): a = etree.Element(NSM + "acc") pr = etree.SubElement(a, NSM + "accPr") ch = etree.SubElement(pr, NSM + "chr") ch.set(NSM + "val", u"\u0304") e = etree.SubElement(a, NSM + "e") getap(nd).append(a) setx(nd, a, e) ct.cnl(nd)
def xtabular(nd): t = etree.Element(NSW+'tbl') pr = etree.SubElement(t, NSW+'tblPr') sty = etree.SubElement(pr, NSW+'tblStyle') sty.set(NSW+'val', 'tbl') jc = etree.SubElement(pr, NSW+'jc') jc.set(NSW+'val', 'center') setx(nd, t, t) getap(nd).append(t) ct.cnl(nd)
def xtabular(nd): t = etree.Element(NSW + 'tbl') pr = etree.SubElement(t, NSW + 'tblPr') sty = etree.SubElement(pr, NSW + 'tblStyle') sty.set(NSW + 'val', 'tbl') jc = etree.SubElement(pr, NSW + 'jc') jc.set(NSW + 'val', 'center') setx(nd, t, t) getap(nd).append(t) ct.cnl(nd)
def xitemize(nd): nr = docx.Numbering num = etree.Element(NSW+'num') num.set(NSW+'numId', nd.id[1:]) nr.append(num) an = etree.SubElement(num, NSW+'abstractNumId') an.set(NSW+'val', '0') lo = itemizeLvlOveride(str(lvl(nd)+1)) num.append(lo) setx(nd, num, getap(nd)) ct.cnl(nd)
def xenumerate(nd): nr = docx.Numbering num = etree.Element(NSW+'num') num.set(NSW+'numId', nd.id[1:]) nr.append(num) an = etree.SubElement(num, NSW+'abstractNumId') an.set(NSW+'val', '0') lo = lvloveride() num.append(lo) setx(nd, num, getap(nd)) ct.cnl(nd)
def xitemize(nd): nr = docx.Numbering num = etree.Element(NSW + 'num') num.set(NSW + 'numId', nd.id[1:]) nr.append(num) an = etree.SubElement(num, NSW + 'abstractNumId') an.set(NSW + 'val', '0') lo = itemizeLvlOveride(str(lvl(nd) + 1)) num.append(lo) setx(nd, num, getap(nd)) ct.cnl(nd)
def xenumerate(nd): nr = docx.Numbering num = etree.Element(NSW + 'num') num.set(NSW + 'numId', nd.id[1:]) nr.append(num) an = etree.SubElement(num, NSW + 'abstractNumId') an.set(NSW + 'val', '0') lo = lvloveride() num.append(lo) setx(nd, num, getap(nd)) ct.cnl(nd)
def xfrac(nd): f = etree.Element(NSM + 'f') fpr = etree.SubElement(f, NSM + 'fPr') tp = etree.SubElement(fpr, NSM + 'type') tp.set(NSM + 'val', 'bar') getap(nd).append(f) num = etree.SubElement(f, NSM + 'num') setx(nd.attributes['numer'], num, num) ct.cnl(nd.attributes['numer']) den = etree.SubElement(f, NSM + 'den') setx(nd.attributes['denom'], den, den) ct.cnl(nd.attributes['denom'])
def xeqnarray(nd): p = etree.Element(NSM + 'oMathPara') m = etree.SubElement(p, NSM + 'oMath') m = etree.SubElement(m, NSM + 'm') m.append(_mpreqa()) getap(nd).append(p) setx(nd, p, m) mmf.push() mmf.set() ct.cnl(nd) mmf.pop()
def xfrac(nd): f = etree.Element(NSM + "f") fpr = etree.SubElement(f, NSM + "fPr") tp = etree.SubElement(fpr, NSM + "type") tp.set(NSM + "val", "bar") getap(nd).append(f) num = etree.SubElement(f, NSM + "num") setx(nd.attributes["numer"], num, num) ct.cnl(nd.attributes["numer"]) den = etree.SubElement(f, NSM + "den") setx(nd.attributes["denom"], den, den) ct.cnl(nd.attributes["denom"])
def xsub(nd): #if nd.previousSibling.nodeName == 'lim': #setap(nd, nd.previousSibling.getUserData('ap')) #ct.cnl(nd) #return ss = setbase(nd) if ss is None: return s = etree.Element(NSM+'sub') setx(nd, s, s) ct.cnl(nd) ss.append(s)
def xsub(nd): #if nd.previousSibling.nodeName == 'lim': #setap(nd, nd.previousSibling.getUserData('ap')) #ct.cnl(nd) #return ss = setbase(nd) if ss is None: return s = etree.Element(NSM + 'sub') setx(nd, s, s) ct.cnl(nd) ss.append(s)
def xeqnarray(nd): p = etree.Element(NSM + "oMathPara") m = etree.SubElement(p, NSM + "oMath") m = etree.SubElement(m, NSM + "m") m.append(_mpreqa()) getap(nd).append(p) setx(nd, p, m) mmf.push() mmf.set() ct.cnl(nd) mmf.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 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 tc(nd): c = etree.Element(NSW+'tc') cp = etree.SubElement(c, NSW+'tcPr') if 'colspan' in nd.attributes: gs = etree.SubElement(cp, NSW+'gridSpan') gs.set(NSW+'val', str(nd.attributes['colspan'])) bd = etree.SubElement(cp, NSW+'tcBorders') if 'border-top-style' in nd.style: tb = etree.SubElement(bd, NSW+'top') if nd.style['border-top-style'] == 'solid': tb.set(NSW+'val', 'single') if 'border-bottom-style' in nd.style: bb = etree.SubElement(bd, NSW+'bottom') if nd.style['border-bottom-style'] == 'solid': bb.set(NSW+'val', 'single') if 'border-left' in nd.style: sb = etree.SubElement(bd, NSW+'start') s = nd.style['border-left'].split() if s[1] == 'solid': sb.set(NSW+'val', 'single') if 'border-right' in nd.style: eb = etree.SubElement(bd, NSW+'end') s = nd.style['border-right'].split() if s[1] == 'solid': eb.set(NSW+'val', 'single') if nd.style['text-align'] == 'center': dc.ac = 'c' elif nd.style['text-align'] == 'right': dc.ac = 'r' elif nd.style['text-align'] == 'left': dc.ac = 'l' getap(nd).append(c) if nd.childNodes: setx(nd,c,c) ct.cnl(nd) p = c.find(NSW+'p') if p == None: p = etree.SubElement(c, NSW+'p') par.setAlign(p) dc.acPop()
def xdisplaymath(nd): ap = getap(nd) if nd.previousSibling != None: ap.append(etree.Element(NSW + 'br')) mmf.push() mmf.set() p = etree.Element(NSM + 'oMathPara') m = etree.SubElement(p, NSM + 'oMath') setx(nd, p, m) ct.cnl(nd) ap.append(p) mmf.pop() if nd.previousSibling != None: ap.append(etree.Element(NSW + 'br'))
def tc(nd): c = etree.Element(NSW + 'tc') cp = etree.SubElement(c, NSW + 'tcPr') if 'colspan' in nd.attributes: gs = etree.SubElement(cp, NSW + 'gridSpan') gs.set(NSW + 'val', str(nd.attributes['colspan'])) bd = etree.SubElement(cp, NSW + 'tcBorders') if 'border-top-style' in nd.style: tb = etree.SubElement(bd, NSW + 'top') if nd.style['border-top-style'] == 'solid': tb.set(NSW + 'val', 'single') if 'border-bottom-style' in nd.style: bb = etree.SubElement(bd, NSW + 'bottom') if nd.style['border-bottom-style'] == 'solid': bb.set(NSW + 'val', 'single') if 'border-left' in nd.style: sb = etree.SubElement(bd, NSW + 'start') s = nd.style['border-left'].split() if s[1] == 'solid': sb.set(NSW + 'val', 'single') if 'border-right' in nd.style: eb = etree.SubElement(bd, NSW + 'end') s = nd.style['border-right'].split() if s[1] == 'solid': eb.set(NSW + 'val', 'single') if nd.style['text-align'] == 'center': dc.ac = 'c' elif nd.style['text-align'] == 'right': dc.ac = 'r' elif nd.style['text-align'] == 'left': dc.ac = 'l' getap(nd).append(c) if nd.childNodes: setx(nd, c, c) ct.cnl(nd) p = c.find(NSW + 'p') if p == None: p = etree.SubElement(c, NSW + 'p') par.setAlign(p) dc.acPop()
def xdisplaymath(nd): ap = getap(nd) if nd.previousSibling != None: ap.append(etree.Element(NSW + "br")) mmf.push() mmf.set() p = etree.Element(NSM + "oMathPara") m = etree.SubElement(p, NSM + "oMath") setx(nd, p, m) ct.cnl(nd) ap.append(p) mmf.pop() if nd.previousSibling != None: ap.append(etree.Element(NSW + "br"))
def xmath(nd): mmf.push() mmf.set() if ntf.isset(): ntf.push() ntf.clear() setap(nd, getap(nd)) ct.cnl(nd) ntf.pop() else: e = etree.Element(NSM + "oMath") setx(nd, e, e) ct.cnl(nd) getap(nd).append(e) mmf.pop()
def xmath(nd): mmf.push() mmf.set() if ntf.isset(): ntf.push() ntf.clear() setap(nd, getap(nd)) ct.cnl(nd) ntf.pop() else: e = etree.Element(NSM + 'oMath') setx(nd, e, e) ct.cnl(nd) getap(nd).append(e) mmf.pop()
def xdelim(nd): d = etree.Element(NSM + "d") dpr = etree.SubElement(d, NSM + "dPr") bc = etree.SubElement(dpr, NSM + "begChr") if nd.attributes["bchar"].textContent != ".": bc.set(NSM + "val", nd.attributes["bchar"].textContent) else: bc.set(NSM + "val", "") ec = etree.SubElement(dpr, NSM + "endChr") if nd.attributes["echar"].textContent != ".": ec.set(NSM + "val", nd.attributes["echar"].textContent) else: ec.set(NSM + "val", "") e = etree.SubElement(d, NSM + "e") setx(nd, d, e) getap(nd).append(d) ct.cnl(nd)
def xdelim(nd): d = etree.Element(NSM + 'd') dpr = etree.SubElement(d, NSM + 'dPr') bc = etree.SubElement(dpr, NSM + 'begChr') if nd.attributes['bchar'].textContent != '.': bc.set(NSM + 'val', nd.attributes['bchar'].textContent) else: bc.set(NSM + 'val', '') ec = etree.SubElement(dpr, NSM + 'endChr') if nd.attributes['echar'].textContent != '.': ec.set(NSM + 'val', nd.attributes['echar'].textContent) else: ec.set(NSM + 'val', '') e = etree.SubElement(d, NSM + 'e') setx(nd, d, e) getap(nd).append(d) ct.cnl(nd)
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 itempar(nd): p = etree.Element(NSW + 'p') pr = etree.SubElement(p, NSW + 'pPr') l = lvl(nd) if nd.previousSibling != None: ind = etree.SubElement(pr, NSW + 'ind') li = str((l + 1) * 420) ind.set(NSW + 'left', li) #Left Indentation else: np = etree.SubElement(pr, NSW + 'numPr') ilv = etree.SubElement(np, NSW + 'ilvl') ilv.set(NSW + 'val', str(l)) nid = etree.SubElement(np, NSW + 'numId') nid.set(NSW + 'val', nd.parentNode.parentNode.id[1:]) fl = etree.SubElement(pr, NSW + 'ind') fl.set(NSW + 'firstLineChars', '0') li = str((l + 1) * 420) fl.set(NSW + 'left', li) #Left Indentation fl.set(NSW + 'hanging', '420') getap(nd).append(p) setx(nd, p, p) ct.cnl(nd)
def itempar(nd): p = etree.Element(NSW+'p') pr = etree.SubElement(p, NSW+'pPr') l = lvl(nd) if nd.previousSibling!=None: ind = etree.SubElement(pr, NSW+'ind') li = str((l+1)*420) ind.set(NSW+'left', li) #Left Indentation else: np = etree.SubElement(pr, NSW+'numPr') ilv = etree.SubElement(np, NSW+'ilvl') ilv.set(NSW+'val', str(l)) nid = etree.SubElement(np, NSW+'numId') nid.set(NSW+'val', nd.parentNode.parentNode.id[1:]) fl = etree.SubElement(pr, NSW+'ind') fl.set(NSW+'firstLineChars', '0') li = str((l+1)*420) fl.set(NSW+'left', li) #Left Indentation fl.set(NSW+'hanging', '420') getap(nd).append(p) setx(nd, p, p) ct.cnl(nd)
def xArrayCell(nd): e = etree.Element(NSM + "e") getap(nd).append(e) setx(nd, e, e) ct.cnl(nd)
def xarray(nd): m = etree.Element(NSM + "m") getap(nd).append(m) setx(nd, m, m) ct.cnl(nd)
def tr(nd): r = etree.Element(NSW + 'tr') getap(nd).append(r) setx(nd, r, r) ct.cnl(nd)
def xdoc(nd): setx(nd, Document, Document) ct.cnl(nd)
def xArrayCell(nd): e = etree.Element(NSM + 'e') getap(nd).append(e) setx(nd, e, e) ct.cnl(nd)
def xdocument(nd): setx(nd, Body, Body) ct.cnl(nd)
def xarray(nd): m = etree.Element(NSM + 'm') getap(nd).append(m) setx(nd, m, m) ct.cnl(nd)
def tr(nd): r = etree.Element(NSW+'tr') getap(nd).append(r) setx(nd, r, r) ct.cnl(nd)