예제 #1
0
 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)
예제 #2
0
    def digest(self, tokens):
        Environment.digest(self, tokens)

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

        self.applyBorders()

        self.linkCells()
예제 #3
0
    def digest(self, tokens):
        Environment.digest(self, tokens)

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

        self.applyBorders()

        self.linkCells()
예제 #4
0
파일: Lists.py 프로젝트: go38/exeLearning
    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) 
예제 #5
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) 
예제 #6
0
 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)
예제 #7
0
파일: alltt.py 프로젝트: ugoertz/plastex
 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)
예제 #8
0
    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
예제 #9
0
 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
예제 #10
0
 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
예제 #11
0
    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
예제 #12
0
 def invoke(self, tex):
     res = Environment.invoke(self, tex)
     a = self.attributes
     if a.get('options'):
         if a['options'].get('colback'):
             a['colback'] = latex2htmlcolor(a['options']['colback'],
                                            named=self.ownerDocument.userdata.getPath('packages/color/colors'))
     return res
예제 #13
0
    def invoke(self, tex):
        res = Environment.invoke(self, tex)

        # Set initial counter values
        for name, value in self.config["counters"]["counters"].items():
            self.ownerDocument.context.counters[name].setcounter(value - 1)

        return res
예제 #14
0
 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
예제 #15
0
    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()
예제 #16
0
    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 'colspec' in list(self.attributes.keys()):
            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')]
예제 #17
0
    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()
예제 #18
0
    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')]
예제 #19
0
 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
예제 #20
0
 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)
예제 #21
0
파일: Lists.py 프로젝트: go38/exeLearning
 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+1, len(List.counters)):
             self.ownerDocument.context.counters[List.counters[i]].setcounter(0)
     except (IndexError, KeyError):
         pass
     return Environment.invoke(self, tex)
예제 #22
0
    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
예제 #23
0
    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
예제 #24
0
    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
예제 #25
0
    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
예제 #26
0
    def postParse(self, tex):
        res = Environment.postParse(self, tex)
        var = self.ownerDocument.userdata['variant']
        self.variantMarkString = 'num_v%d' % var

        while not self.attributes[self.variantMarkString] :
            var = var - 1
            self.variantMarkString = 'num_v%d' % var

        try:
            self.mark = int(self.attributes[self.variantMarkString])
            self.markText = "%d mark" % self.mark
            if self.mark != 1:
                self.markText += "s"
        except:
            self.hidden = True
            self.ownerDocument.context.counters['question'].value -= 1
        return res
예제 #27
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]
                    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
예제 #28
0
 def digest(self, tokens):
     tokens.push(self.ownerDocument.createElement('par'))
     Environment.digest(self, tokens)
예제 #29
0
 def digest(self, tokens):
     res = Environment.digest(self, tokens)
     if self.macroMode == self.MODE_BEGIN:
         self.ownerDocument.userdata['abstract'] = self
     return res
예제 #30
0
 def digest(self, tokens):
     tokens.push(self.ownerDocument.createElement('par'))
     Environment.digest(self, tokens)
예제 #31
0
 def normalize(self, charsubs=None):
     """ Normalize, but don't allow character substitutions """
     return Environment.normalize(self)
예제 #32
0
 def normalize(self, charsubs=None):
     return Environment.normalize(self, charsubs=None)
예제 #33
0
 def normalize(self, charsubs=None):
     """ Normalize, but don't allow character substitutions """
     return Environment.normalize(self, charsubs=None)
예제 #34
0
 def digest(self, tokens):
     Environment.digest(self, tokens)
     self.caption = self.attributes.get('caption', '')
예제 #35
0
 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)
예제 #36
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
예제 #37
0
 def digest(self, tokens):
     Environment.digest(self, tokens)
     self.caption = self.attributes.get('caption', '')