示例#1
0
 def prepareNode(self, dstree, dsnode, level, indent = None):
     curLevel     = util.levelToInt(DocumentStructure.getLevel(dsnode))
     levelAbove   = util.levelToInt(util.levelAbove(level))
     levelDesired = util.levelToInt(level)
     
     if curLevel >= levelAbove:
         while curLevel > levelAbove:
             newLevel = util.levelBelow(DocumentStructure.getLevel(dsnode))
             dsnode = dstree.addNode(dsnode, level = newLevel, indent = indent)
             curLevel = util.levelToInt(DocumentStructure.getLevel(dsnode))
             
         if level == DocumentStructure.PARAGRAPH:
             self.preInsertedParagraph = True
             dsnode = dstree.addNode(dsnode, level = DocumentStructure.PARAGRAPH, indent = indent)
         else:
             self.preInsertedParagraph = False
             
     elif curLevel < levelAbove:
         while curLevel < levelDesired:
             dsnode = dsnode.getparent()
             curLevel = util.levelToInt(DocumentStructure.getLevel(dsnode))
             
         if level != DocumentStructure.PARAGRAPH:
             dsnode = dsnode.getparent()
             
         DocumentStructure.setIndent(dsnode, indent)
             
     return dsnode
示例#2
0
 def __handle_blockquote__(self, xmlnode, dstree, dsnode):
     # Ignore inner value, text data is not allowed
     valueTail = xmlnode.tail
     
     # Encounter paragraph data assumed to be without a pre-inserted p entry
     if valueTail != None and len(valueTail.strip()) > 0:
         dsnodeParent = dsnode
         if util.getLevel(dsnodeParent) != util.levelAbove(DocumentStructure.PARAGRAPH):
             dsnodeParent = util.getparent(dstree, dsnode)
         self.peudodsnode = dstree.addNode(dsnodeParent, DocumentStructure.PARAGRAPH, value = valueTail)
         self.peudodsnodereplace = dsnode
     
     return dsnode
示例#3
0
 def __handle_p__(self, xmlnode, dstree, dsnode):
     # End a pseudo-p trigger
     if self.peudoTrigger == True:
         self.peudoTrigger = False
         dsnode = self.peudodsnodereplace
         self.peudodsnodereplace = None
         self.peudodsnode = None
     
     valueText = xmlnode.text
     valueTail = xmlnode.tail
     
     if valueText != None:
         valueText = valueText.strip()
     if valueTail != None:
         valueTail = valueTail.strip()
     
     # Encounter a p tag with a pre-inserted p entry
     if self.preInsertedParagraph == True:
         dsnode = self.prepareNode(dstree, dsnode, DocumentStructure.PARAGRAPH)
         self.abstractHandler.handleReplace(dstree, dsnode, valueText)
         
     # Encounter a p tag without a pre-inserted p entry
     else:
         dsnode = self.prepareNode(dstree, dsnode, DocumentStructure.PARAGRAPH)
             
         if self.preInsertedParagraph != True:
             dsnode = self.prepareNode(dstree, dsnode, DocumentStructure.PARAGRAPH)
             dsnode = util.getparent(dstree, dsnode)
             dsnode = dstree.addNode(dsnode, level = DocumentStructure.PARAGRAPH, value = valueText)
         else:
             self.abstractHandler.handleReplace(dstree, dsnode, valueText)
                 
         self.preInsertedParagraph = False
                     
     # Encounter a p tag without a pre-inserted p entry
     if valueTail != None and len(valueTail.strip()) > 0:
         dsnodeParent = dsnode
         if util.getLevel(dsnodeParent) != util.levelAbove(DocumentStructure.PARAGRAPH):
             dsnodeParent = util.getparent(dstree, dsnode)
         self.peudodsnode = dstree.addNode(dsnodeParent, DocumentStructure.PARAGRAPH, value = valueTail)
         self.peudodsnodereplace = dsnode
         
     return self.handleIndent(dsnode, xmlnode)