Example #1
0
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()
Example #2
0
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)
Example #3
0
def xquote(nd):
    p = getap(nd)
    pr = p.find('.//'+NSW+'pPr')
    if pr==None:
        pr = etree.SubElement(p, NSW+'pPr')
        ind = etree.SubElement(pr, NSW+'ind')
        ind.set(NSW+'left','420')
        ind.set(NSW+'right','420')
    else:
        ind = pr.find('.//'+NSW+'ind')
        if ind == None:
            ind = etree.SubElement(pr, NSW+'ind')
            ind.set(NSW+'left','420')
            ind.set(NSW+'right','420')
        else:
            left = ind.get(NSW+'left')
            if left == None:
                left = '420'
            else:
                left = str(int(left)+420)
            ind.set(NSW+'left',left)
            right = ind.get(NSW+'right')
            if right == None:
                right = '420'
            else:
                right = str(int(right)+420)
            ind.set(NSW+'right',right)
    setap(nd, p)
    ct.cnl(nd)
Example #4
0
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()
Example #5
0
def xtitle(nd):
    npf.push()
    p = spar('title')
    _mt['title'] = p
    setx(nd, p, p)
    ct.cnl(nd)
    npf.pop()
Example #6
0
def xauthor(nd):
    npf.push()
    p = spar('author')
    _mt['author'] = p
    setx(nd, p, p)
    ct.cnl(nd)
    npf.pop()
Example #7
0
def xauthor(nd):
    npf.push()
    p = spar('author')
    _mt['author'] = p
    setx(nd, p, p)
    ct.cnl(nd)
    npf.pop()
Example #8
0
def xdate(nd):
    npf.push()
    p = spar('author')
    _mt['date'] = p
    setx(nd, p, p)
    ct.cnl(nd)
    npf.pop()
Example #9
0
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)
Example #10
0
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)
Example #11
0
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)
Example #12
0
def xdate(nd):
    npf.push()
    p = spar('author')
    _mt['date'] = p
    setx(nd, p, p)
    ct.cnl(nd)
    npf.pop()
Example #13
0
def xtitle(nd):
    npf.push()
    p = spar('title')
    _mt['title'] = p
    setx(nd, p, p)
    ct.cnl(nd)
    npf.pop()
Example #14
0
def xquote(nd):
    p = getap(nd)
    pr = p.find('.//' + NSW + 'pPr')
    if pr == None:
        pr = etree.SubElement(p, NSW + 'pPr')
        ind = etree.SubElement(pr, NSW + 'ind')
        ind.set(NSW + 'left', '420')
        ind.set(NSW + 'right', '420')
    else:
        ind = pr.find('.//' + NSW + 'ind')
        if ind == None:
            ind = etree.SubElement(pr, NSW + 'ind')
            ind.set(NSW + 'left', '420')
            ind.set(NSW + 'right', '420')
        else:
            left = ind.get(NSW + 'left')
            if left == None:
                left = '420'
            else:
                left = str(int(left) + 420)
            ind.set(NSW + 'left', left)
            right = ind.get(NSW + 'right')
            if right == None:
                right = '420'
            else:
                right = str(int(right) + 420)
            ind.set(NSW + 'right', right)
    setap(nd, p)
    ct.cnl(nd)
Example #15
0
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)
Example #16
0
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)
Example #17
0
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)
Example #18
0
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)
Example #19
0
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)
Example #20
0
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)
Example #21
0
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)
Example #22
0
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)
Example #23
0
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)
Example #24
0
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)
Example #25
0
def xbgroup(nd):
    rif.push()
    rif.clear()
    rbf.push()
    rbf.clear()
    setap(nd, getap(nd))
    ct.cnl(nd)
    rbf.pop()
    rif.pop()
Example #26
0
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)
Example #27
0
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)
Example #28
0
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)
Example #29
0
def limlow(nd, s):
    ll = etree.Element(NSM + "limLow")
    e = etree.SubElement(ll, NSM + "e")
    e.append(txt.pmtr(s))
    l = etree.SubElement(ll, NSM + "lim")
    getap(nd).append(ll)
    ns = nd.nextSibling
    if ns.nodeName == "active::_":
        setap(ns, l)
        ct.cnl(ns)
        nd.parentNode.removeChild(ns)
Example #30
0
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)
Example #31
0
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)
Example #32
0
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)
Example #33
0
def limlow(nd, s):
    ll = etree.Element(NSM + 'limLow')
    e = etree.SubElement(ll, NSM + 'e')
    e.append(txt.pmtr(s))
    l = etree.SubElement(ll, NSM + 'lim')
    getap(nd).append(ll)
    ns = nd.nextSibling
    if ns.nodeName == 'active::_':
        setap(ns, l)
        ct.cnl(ns)
        nd.parentNode.removeChild(ns)
Example #34
0
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"])
Example #35
0
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'])
Example #36
0
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()
Example #37
0
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)
Example #38
0
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()
Example #39
0
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)
Example #40
0
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()
Example #41
0
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()
Example #42
0
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()
Example #43
0
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'))
Example #44
0
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()
Example #45
0
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"))
Example #46
0
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()
Example #47
0
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()
Example #48
0
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)
Example #49
0
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)
Example #50
0
def xthanks(nd):
    def fr(sr):
        r = etree.Element(NSW+'r')
        rpr = etree.SubElement(r, NSW+'rPr')
        rs = etree.SubElement(rpr, NSW+'rStyle')
        rs.set(NSW+'val', 'sup')
        fr = etree.SubElement(r, NSW+sr)
        fr.set(NSW+'id', i)
        return r
    i = nd.id[1:]
    f = etree.Element(NSW+'footnote')
    f.set(NSW+'id', i)
    p = etree.SubElement(f, NSW+'p')
    setap(nd, p)
    p.append(fr('footnoteRef'))
    ct.cnl(nd)
    getap(nd).append(fr('footnoteReference'))
    docx.Footnotes.append(f)
Example #51
0
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()
Example #52
0
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()
Example #53
0
def xthanks(nd):
    def fr(sr):
        r = etree.Element(NSW + 'r')
        rpr = etree.SubElement(r, NSW + 'rPr')
        rs = etree.SubElement(rpr, NSW + 'rStyle')
        rs.set(NSW + 'val', 'sup')
        fr = etree.SubElement(r, NSW + sr)
        fr.set(NSW + 'id', i)
        return r

    i = nd.id[1:]
    f = etree.Element(NSW + 'footnote')
    f.set(NSW + 'id', i)
    p = etree.SubElement(f, NSW + 'p')
    setap(nd, p)
    p.append(fr('footnoteRef'))
    ct.cnl(nd)
    getap(nd).append(fr('footnoteReference'))
    docx.Footnotes.append(f)
Example #54
0
def narg(nd, char):
    n = etree.Element(NSM + 'nary')
    getap(nd).append(n)

    np = etree.SubElement(n, NSM + 'naryPr')
    ch = etree.SubElement(np, NSM + 'chr')
    ch.set(NSM + 'val', char)
    subHide = etree.SubElement(np, NSM + 'subHide')
    subHide.set(NSM + 'val', '1')
    supHide = etree.SubElement(np, NSM + 'supHide')
    supHide.set(NSM + 'val', '1')

    e = etree.SubElement(n, NSM + 'e')
    d = nd.ownerDocument.createDocumentFragment()
    setap(d, e)
    ns = nd.nextSibling

    try:
        for x in range(0, 2):
            if ns.nodeName == 'active::_':
                s = etree.SubElement(n, NSM + 'sub')
                subHide.set(NSM + 'val', '0')
                setap(ns, s)
                ct.cnl(ns)
            elif ns.nodeName == 'active::^':
                s = etree.SubElement(n, NSM + 'sup')
                supHide.set(NSM + 'val', '0')
                setap(ns, s)
                ct.cnl(ns)
            else:
                while ns is not None:
                    d.appendChild(ns)
                    nd.parentNode.removeChild(ns)
                    ns = nd.nextSibling
                ct.cnl(d)
                return
            nd.parentNode.removeChild(ns)
            ns = nd.nextSibling
            if nd.nodeType == 3 and ns.isspace():
                nd.parentNode.removeChild(ns)
                ns = nd.nextSibling

        while ns is not None:
            d.appendChild(ns)
            nd.parentNode.removeChild(ns)
            ns = nd.nextSibling
        ct.cnl(d)
        return
    except AttributeError:
        return
Example #55
0
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)
Example #56
0
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)
Example #57
0
def narg(nd, char):
    n = etree.Element(NSM + "nary")
    getap(nd).append(n)

    np = etree.SubElement(n, NSM + "naryPr")
    ch = etree.SubElement(np, NSM + "chr")
    ch.set(NSM + "val", char)
    subHide = etree.SubElement(np, NSM + "subHide")
    subHide.set(NSM + "val", "1")
    supHide = etree.SubElement(np, NSM + "supHide")
    supHide.set(NSM + "val", "1")

    e = etree.SubElement(n, NSM + "e")
    d = nd.ownerDocument.createDocumentFragment()
    setap(d, e)
    ns = nd.nextSibling

    try:
        for x in range(0, 2):
            if ns.nodeName == "active::_":
                s = etree.SubElement(n, NSM + "sub")
                subHide.set(NSM + "val", "0")
                setap(ns, s)
                ct.cnl(ns)
            elif ns.nodeName == "active::^":
                s = etree.SubElement(n, NSM + "sup")
                supHide.set(NSM + "val", "0")
                setap(ns, s)
                ct.cnl(ns)
            else:
                while ns is not None:
                    d.appendChild(ns)
                    nd.parentNode.removeChild(ns)
                    ns = nd.nextSibling
                ct.cnl(d)
                return
            nd.parentNode.removeChild(ns)
            ns = nd.nextSibling
            if nd.nodeType == 3 and ns.isspace():
                nd.parentNode.removeChild(ns)
                ns = nd.nextSibling

        while ns is not None:
            d.appendChild(ns)
            nd.parentNode.removeChild(ns)
            ns = nd.nextSibling
        ct.cnl(d)
        return
    except AttributeError:
        return
Example #58
0
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)
Example #59
0
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)