Example #1
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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
0
def xbgroup(nd):
    rif.push()
    rif.clear()
    rbf.push()
    rbf.clear()
    setap(nd, getap(nd))
    ct.cnl(nd)
    rbf.pop()
    rif.pop()
Example #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
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 #17
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 #18
0
def xitem(nd):
    setap(nd, getap(nd))
    ct.cnl(nd)
Example #19
0
def xtext(nd):
    ntf.push()
    ntf.set()
    setap(nd, getap(nd))
    ct.cnl(nd)
    ntf.pop()
Example #20
0
def xitem(nd):
    setap(nd, getap(nd))
    ct.cnl(nd)
Example #21
0
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)
Example #22
0
def xem(nd):
    rif.set()
    setap(nd, getap(nd))
    ct.cnl(nd)
    rif.clear()
Example #23
0
def xcite(nd):
    f = nd.citation()
    setap(f, getap(nd))
    ct.cnl(f)
Example #24
0
def xcite(nd):
    f = nd.citation()
    setap(f, getap(nd))
    ct.cnl(f)
Example #25
0
def xtexttt(nd):
    ttf.set()
    setap(nd, getap(nd))
    ct.cnl(nd)
    ttf.clear()
Example #26
0
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)
Example #27
0
def xbf(nd):
    rbf.set()
    setap(nd, getap(nd))
    ct.cnl(nd)
    rbf.clear()
Example #28
0
def xtext(nd):
    ntf.push()
    ntf.set()
    setap(nd, getap(nd))
    ct.cnl(nd)
    ntf.pop()