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 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()
from plasTeX.TeX import TeX from lxml import etree import ct, docx from common import Document import sys, os try: tf = sys.argv[1] except: print 'useage: Latex2docx texfile' sys.exit(0) try: df = os.path.splitext(tf)[0] td = TeX(file=tf) td = td.parse() ct.cnd(td) docx.save(df) except OSError as oe: print oe except IOError as oe: print oe
from plasTeX.TeX import TeX from lxml import etree import ct, docx from common import Document td = TeX(file='nt.tex') td = td.parse() print print td.toXML() print ct.cnd(td) #print etree.tostring(Document, encoding='utf-8', xml_declaration=True, standalone=True, pretty_print=True) docx.save('sd')