コード例 #1
0
ファイル: Arrays.py プロジェクト: PatrickMassot/plastex
    def digest(self, tokens):
        Environment.digest(self, tokens)

        # Give subclasses a hook before going on
        self.processRows()

        self.applyBorders()

        self.linkCells()
コード例 #2
0
ファイル: Lists.py プロジェクト: Chuvi-w/lisiynos
    def digest(self, tokens):
        if self.macroMode != Environment.MODE_END:
            # Drop any whitespace before the first item
            for tok in tokens:
                if tok.isElementContentWhitespace:
                    continue
#               if tok.nodeName != 'item':
#                   log.warning('dropping non-item from beginning of list')
#                   continue
                tokens.push(tok)
                break
        Environment.digest(self, tokens) 
コード例 #3
0
ファイル: Floats.py プロジェクト: AllenDowney/plastex-oreilly
    def digest(self, tokens):
        res = Environment.digest(self, tokens)

        loc = self.attributes.get('loc')
        if loc and 'h' in loc:
            self.float = False
        else:
            self.float = True

        # Apply captions to objects
        if self.macroMode == self.MODE_BEGIN:
            # Locate all caption nodes and nodes that are 
            # capable of being captioned.
            all = self.allChildNodes
            captions = [x for x in all if isinstance(x, (Caption, Array.caption))]
            objects = [x for x in all if getattr(x, 'captionable', False)] 
            # If there is only one caption, apply it to the float
            if len(captions) == 1:
                captions[0].attached = True
                self.title = captions[0]
            # If there are the same number of captions as there are
            # captionable items, apply the captions to the objects.
            if len(captions) == len(objects):
                while captions and objects:
                    captions[0].attached = True
                    objects.pop(0).title = captions.pop(0)
        return res
コード例 #4
0
ファイル: Arrays.py プロジェクト: NextThought/nti.plasTeX
    def digest(self, tokens):
        # If any of our ancestors are in Math Mode, we should be also.
        # Otherwise our source property returns LaTeX with too many
        # line breaks.
        parentNode = self.parentNode
        while(hasattr(parentNode, 'mathMode') and parentNode.parentNode is not None):
            if parentNode.mathMode:
                self.mathMode = parentNode.mathMode
                break
            parentNode = parentNode.parentNode

        Environment.digest(self, tokens)

        # Give subclasses a hook before going on
        self.processRows()

        self.applyBorders()

        self.linkCells()
コード例 #5
0
 def digest(self, tokens):
     res = Environment.digest(self, tokens)
     # Apply captions to objects
     if self.macroMode == self.MODE_BEGIN:
         # Locate all caption nodes and nodes that are
         # capable of being captioned.
         all = self.allChildNodes
         captions = [
             x for x in all if isinstance(x, (Caption, Array.caption))
         ]
         objects = [x for x in all if getattr(x, 'captionable', False)]
         # If there is only one caption, apply it to the float
         if len(captions) == 1:
             captions[0].attached = True
             self.title = captions[0]
         # If there are the same number of captions as there are
         # captionable items, apply the captions to the objects.
         if len(captions) == len(objects):
             while captions and objects:
                 captions[0].attached = True
                 objects.pop(0).title = captions.pop(0)
     return res
コード例 #6
0
    def digest(self, tokens):
        """ Sort and group index entries """
        if isinstance(self, Environment):
            Environment.digest(self, tokens)
            if self.macroMode == self.MODE_END:
                return
            # Throw it all away, we don't need it.  We'll be generating
            # our own index entries below.
            while self.childNodes:
                self.pop()
        else:
            Command.digest(self, tokens)
        doc = self.ownerDocument
        current = self
        entries = sorted(self.ownerDocument.userdata.get('index', []))
        prev = IndexEntry([], None)
        for item in entries:
            # See how many levels we need to add/subtract between this one
            # and the previous
            common = 0
            for prevkey, itemkey in zip(zip(prev.sortkey, prev.key),
                                        zip(item.sortkey, item.key)):
                if prevkey == itemkey:
                    common += 1
                    continue
                break

#           print
#           print item
#           print (prev.key, prev.sortkey), (item.key, item.sortkey), common

            # Pop out to the common level
            i = common
            while i < len(prev.key):
#               print 'POP'
                current = current.parentNode
                i += 1

            # Add the appropriate number of levels
            i = common
            while i < len(item.key):
#               print 'ADD', item.sortkey[i]
                newidx = self.Index()
                newidx.key = item.key[i]
                newidx.sortkey = item.sortkey[i]
                newidx.parentNode = current
                current.append(newidx)
                current = newidx
                i += 1

            # Add the current page and format it
            current.pages.append(IndexDestination(item.type, item.node))
            if item.format is not None:
                text = doc.createTextNode(str(len(current.pages)))
                ipn = item.format.getElementsByTagName('index-page-number')
                if ipn:
                    ipn = ipn[0]
                    ipn.parentNode.replaceChild(text, ipn)
                item.node.append(item.format)
            else:
                text = doc.createTextNode(str(len(current.pages)))
                item.node.append(text)
            prev = item
コード例 #7
0
 def digest(self, tokens):
     Environment.digest(self, tokens)
     self.caption = self.attributes.get('caption', '')
コード例 #8
0
ファイル: Index.py プロジェクト: NextThought/nti.plasTeX
    def digest(self, tokens):
        """ Sort and group index entries """
        if isinstance(self, Environment):
            Environment.digest(self, tokens)
            if self.macroMode == self.MODE_END:
                return
            # Throw it all away, we don't need it.  We'll be generating
            # our own index entries below.
            while self.childNodes:
                self.pop()
        else:
            Command.digest(self, tokens)
        doc = self.ownerDocument
        current = self
        entries = sorted(self.ownerDocument.userdata.get('index', []))
        prev = IndexEntry([], None)
        for item in entries:
            # See how many levels we need to add/subtract between this one
            # and the previous
            common = 0
            for prevkey, itemkey in zip(zip(prev.sortkey, prev.key),
                                        zip(item.sortkey, item.key)):
                if prevkey == itemkey:
                    common += 1
                    continue
                break

#           print
#           print item
#           print (prev.key, prev.sortkey), (item.key, item.sortkey), common

            # Pop out to the common level
            i = common
            while i < len(prev.key):
#               print 'POP'
                current = current.parentNode
                i += 1

            # Add the appropriate number of levels
            i = common
            while i < len(item.key):
#               print 'ADD', item.sortkey[i]
                newidx = self.Index()
                newidx.key = item.key[i]
                newidx.sortkey = item.sortkey[i]
                newidx.parentNode = current
                current.append(newidx)
                current = newidx
                i += 1

            # Add the current page and format it
            current.pages.append(IndexDestination(item.type, item.node))
            if item.format is not None:
                text = doc.createTextNode(str(len(current.pages)))
                ipn = item.format.getElementsByTagName('index-page-number')
                if ipn:
                    ipn = ipn[0]
                    if ipn.parentNode:
                        ipn.parentNode.replaceChild(text, ipn)
                item.node.append(item.format)
            else:
                text = doc.createTextNode(str(len(current.pages)))
                item.node.append(text)
            prev = item
コード例 #9
0
ファイル: Document.py プロジェクト: sbbzplt/LaTex2Docx
 def digest(self, tokens):
     tokens.push(self.ownerDocument.createElement('par'))
     Environment.digest(self, tokens)
コード例 #10
0
 def digest(self, tokens):
     res = Environment.digest(self, tokens)
     if self.macroMode == self.MODE_BEGIN:
         self.ownerDocument.userdata['abstract'] = self
     return res
コード例 #11
0
ファイル: Document.py プロジェクト: bahuafeng/LaTex2Docx
 def digest(self, tokens):
     tokens.push(self.ownerDocument.createElement('par'))
     Environment.digest(self, tokens)
コード例 #12
0
ファイル: Definitions.py プロジェクト: PatrickMassot/plastex
 def digest(self, tokens):
     Environment.digest(self, tokens)
     self.caption = self.attributes.get('caption', '')