The node has content marker can disappear (while the node still has
content). This happened when using my close open xml element button,
included below in case it's relevant.  It seems to be working fine,
which is cool.

Cheers -Terry

from xml import sax

class Stacky(sax.handler.ContentHandler):
    def __init__(self): self.stack = []
    def startElement(self, name, attrs):
        self.stack.append(name)
    def endElement(self, name):
        self.stack.pop()

stacky = Stacky()
txt = p.bodyString()
w = c.frame.body.bodyCtrl
pnt = w.getInsertPoint()
xml = txt[:pnt]

try:
    sax.parseString(str(xml), stacky)
except sax.SAXParseException, descrip:
    if 'no element found' not in str(descrip):
        g.es("Error in context '%s'" % '->'.join(stacky.stack))
        raise
    if stacky.stack:
        etag = '</%s>' % stacky.stack[-1]
        c.setBodyString(p, xml + etag + txt[pnt:])
        # insert point moves to end of buffer... so move it back
        w.setInsertPoint(pnt+len(etag))  # unicode safe?
    else:
        raise

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to