def xtext(nd): if nd.parentNode.nodeName == '#document': return s = nd.textContent if not mmf.isset(): p = getap(nd) if len(p) == 0: s = s.lstrip() elif p[-1].tag == NSW+'pPr': s = s.lstrip() #if nd.previousSibling == None: #s = s.lstrip() #elif nd.previousSibling.blockType == True: #s = s.lstrip() #if nd.nextSibling == None: #s = s.rstrip() #if s == '': #return #else: #r = tr(s) if s == '': return r = tr(s) getap(nd).append(r)
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 rpr(): r = None if rif.isset(): if r==None: r = etree.Element(NSW+'rPr') etree.SubElement(r,NSW+'i') if ttf.isset(): if mmf.isset(): if r==None: r = etree.Element(NSM+'rPr') scr = etree.SubElement(r, NSM+'scr') scr.set(NSM+'val', 'monospace') sty = etree.SubElement(r, NSM+'sty') sty.set(NSM+'val', 'p') else: if r==None: r = etree.Element(NSW+'rPr') f = etree.SubElement(r, NSW+'rFonts') f.set(NSW+'ascii', 'Courier New') if rbf.isset(): if r==None: r = etree.Element(NSW+'rPr') etree.SubElement(r,NSW+'b') return r
def tr(s): if mmf.isset(): r = etree.Element(NSM+'r') if rpr()!=None: r.append(rpr()) if ntf.isset(): pr = etree.SubElement(r, NSM+'rPr') etree.SubElement(pr, NSM+'nor') t = etree.SubElement(r,NSM+'t') t.text = s else: t = etree.SubElement(r,NSM+'t') t.text = s.replace(" ", "") npf.set() else: r = etree.Element(NSW+'r') if rpr()!=None: r.append(rpr()) t = etree.SubElement(r,NSW+'t') t.set('{http://www.w3.org/XML/1998/namespace}space','preserve') t.text = s if t.text.isspace()==False: npf.set() return r
def xArrayCell(nd): if mmf.isset(): mm.xArrayCell(nd) return tc(nd)
def xArrayRow(nd): if mmf.isset(): mm.xArrayRow(nd) return tr(nd)