Logo Search packages:      
Sourcecode: zope-backtalk version File versions

def BackTalk::Syntax::Parser::format (   self,
  formatter = None,
  form = None 
)

Parse and send the colored source.

Definition at line 61 of file Syntax.py.

00061                                                :
        """ Parse and send the colored source.
        """
        # store line offsets in self.lines
        self.lines = [0, 0]
        pos = 0
        while 1:
            pos = string.find(self.raw, '\n', pos) + 1
            if not pos: break
            self.lines.append(pos)
        self.lines.append(len(self.raw))

        # parse the source and write it
        self.pos = 0
        text = cStringIO.StringIO(self.raw)
        self.out = self.out + '<pre class="simple_example">'
        try:
            tokenize.tokenize(text.readline, self)
        except tokenize.TokenError, ex:
            msg = ex[0]
            line = ex[1][0]
            self.out = self.out + "<h3>ERROR: %s</h3>%s\n" % (
                msg, self.raw[self.lines[line]:])
        self.out = self.out + '</pre>'

    def __call__(self, toktype, toktext, (srow,scol), (erow,ecol), line):


Generated by  Doxygen 1.6.0   Back to index