当前位置: 首页>>代码示例>>Python>>正文


Python plasTeX.Environment类代码示例

本文整理汇总了Python中plasTeX.Environment的典型用法代码示例。如果您正苦于以下问题:Python Environment类的具体用法?Python Environment怎么用?Python Environment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Environment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: digest

    def digest(self, tokens):
        Environment.digest(self, tokens)

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

        self.applyBorders()

        self.linkCells()
开发者ID:PatrickMassot,项目名称:plastex,代码行数:9,代码来源:Arrays.py

示例2: digest

    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) 
开发者ID:Chuvi-w,项目名称:lisiynos,代码行数:12,代码来源:Lists.py

示例3: invoke

 def invoke(self, tex):
     self.ownerDocument.context.push(self)
     esc = self.ownerDocument.context.categories[Token.CC_ESCAPE]
     begin = self.ownerDocument.context.categories[Token.CC_BGROUP]
     end = self.ownerDocument.context.categories[Token.CC_EGROUP]
     self.ownerDocument.context.setVerbatimCatcodes()
     for i in esc:
         self.ownerDocument.context.catcode(i, Token.CC_ESCAPE)
     for i in begin:
         self.ownerDocument.context.catcode(i, Token.CC_BGROUP)
     for i in end:
         self.ownerDocument.context.catcode(i, Token.CC_EGROUP)
     Environment.invoke(self, tex)
     self.ownerDocument.context.pop(self)
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:14,代码来源:alltt.py

示例4: invoke

 def invoke(self, tex):
     res = Environment.invoke(self, tex)
     if self.macroMode == self.MODE_BEGIN:
         a = self.attributes['place'].lower()
         if a in ['r','o']:
             self.float = 'right'
     return res
开发者ID:AllenDowney,项目名称:plastex-oreilly,代码行数:7,代码来源:wrapfig.py

示例5: digest

    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
开发者ID:AllenDowney,项目名称:plastex-oreilly,代码行数:27,代码来源:Floats.py

示例6: digest

    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()
开发者ID:NextThought,项目名称:nti.plasTeX,代码行数:19,代码来源:Arrays.py

示例7: invoke

 def invoke(self, tex):
     res = Environment.invoke(self, tex)
     doc = self.ownerDocument
     if self.macroMode != self.MODE_END:
         self.ownerDocument.userdata.setPath("babel/previouslanguage", doc.context.currentLanguage)
         doc.context.loadLanguage(self.attributes["lang"], self.ownerDocument)
     else:
         lang = doc.userdata.getPath("babel/previouslanguage")
         doc.context.loadLanguage(lang, self.ownerDocument)
     return res
开发者ID:AllenDowney,项目名称:plastex-oreilly,代码行数:10,代码来源:babel.py

示例8: invoke

    def invoke(self, tex):
        if self.macroMode == Macro.MODE_END:
            self.ownerDocument.context.pop(self) # End of table, row, and cell
            return
        
        Environment.invoke(self, tex)

#!!!
#
# Need to handle colspec processing here so that tokens that must 
# be inserted before and after columns are known
#
#!!!
        if self.attributes.has_key('colspec'):
            self.colspec = Array.compileColspec(tex, self.attributes['colspec'])

        self.ownerDocument.context.push() # Beginning of cell
        # Add a phantom row and cell to absorb the appropriate tokens
        return [self, self.ownerDocument.createElement('ArrayRow'), 
                      self.ownerDocument.createElement('ArrayCell')]
开发者ID:PatrickMassot,项目名称:plastex,代码行数:20,代码来源:Arrays.py

示例9: invoke

 def invoke(self, tex):
     """ Set list nesting depth """
     if self.macroMode != Environment.MODE_END:
         List.depth += 1
     else:
         List.depth -= 1
     try:
         for i in range(List.depth, len(List.counters)):
             self.ownerDocument.context.counters[List.counters[i]].setcounter(0)
     except (IndexError, KeyError):
         pass
     return Environment.invoke(self, tex)
开发者ID:AllenDowney,项目名称:plastex-oreilly,代码行数:12,代码来源:Lists.py

示例10: invoke

    def invoke(self, tex):
        res = Environment.invoke(self, tex)

        # Set initial counter values
        if self.config.has_key("counters"):
            counters = self.config["counters"]
            for name in counters.keys():
                if name.startswith(";"):
                    continue
                self.ownerDocument.context.counters[name].setcounter(counters[name] - 1)

        return res
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:12,代码来源:Document.py

示例11: invoke

    def invoke(self, tex):
        res = Environment.invoke(self, tex)

        # Set initial counter values
        if 'counters' in self.config:
            counters = self.config['counters']
            for name in list(counters.keys()):
                if name.startswith(';'):
                    continue
                try:
                    self.ownerDocument.context.counters[name].setcounter(counters[name]-1)
                except TypeError:
                    self.ownerDocument.context.counters[name].setcounter(int(counters[name])-1)

        return res
开发者ID:NextThought,项目名称:nti.plasTeX,代码行数:15,代码来源:Document.py

示例12: invoke

 def invoke(self, tex):
     if isinstance(self, Environment):
         Environment.invoke(self, tex)
     else:
         Command.invoke(self, tex)
     self.attributes['title'] = self.ownerDocument.createElement('indexname').expand(tex)
开发者ID:NextThought,项目名称:nti.plasTeX,代码行数:6,代码来源:Index.py

示例13: digest

    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
开发者ID:NextThought,项目名称:nti.plasTeX,代码行数:64,代码来源:Index.py

示例14: normalize

 def normalize(self, charsubs=None):
     """ Normalize, but don't allow character substitutions """
     return Environment.normalize(self)
开发者ID:PatrickMassot,项目名称:plastex,代码行数:3,代码来源:Verbatim.py

示例15: digest

 def digest(self, tokens):
     tokens.push(self.ownerDocument.createElement('par'))
     Environment.digest(self, tokens)
开发者ID:bahuafeng,项目名称:LaTex2Docx,代码行数:3,代码来源:Document.py


注:本文中的plasTeX.Environment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。