Show More
@@ -137,7 +137,7 b' class Parser:' | |||
|
137 | 137 | out should be a file-type object. Optionally, out can be given as the |
|
138 | 138 | string 'str' and the parser will automatically return the output in a |
|
139 | 139 | string.""" |
|
140 | ||
|
140 | ||
|
141 | 141 | string_output = 0 |
|
142 | 142 | if out == 'str' or self.out == 'str' or \ |
|
143 | 143 | isinstance(self.out,StringIO.StringIO): |
@@ -159,14 +159,14 b' class Parser:' | |||
|
159 | 159 | return raw,error |
|
160 | 160 | else: |
|
161 | 161 | return None,error |
|
162 | ||
|
162 | ||
|
163 | 163 | # local shorthands |
|
164 | 164 | colors = self.color_table[scheme].colors |
|
165 | 165 | self.colors = colors # put in object so __call__ sees it |
|
166 | 166 | |
|
167 | 167 | # Remove trailing whitespace and normalize tabs |
|
168 | 168 | self.raw = raw.expandtabs().rstrip() |
|
169 | ||
|
169 | ||
|
170 | 170 | # store line offsets in self.lines |
|
171 | 171 | self.lines = [0, 0] |
|
172 | 172 | pos = 0 |
@@ -217,11 +217,6 b' class Parser:' | |||
|
217 | 217 | newpos = self.lines[srow] + scol |
|
218 | 218 | self.pos = newpos + len(toktext) |
|
219 | 219 | |
|
220 | # handle newlines | |
|
221 | #if toktype in [token.NEWLINE, tokenize.NL]: | |
|
222 | # owrite(linesep) | |
|
223 | # return | |
|
224 | ||
|
225 | 220 | # send the original whitespace, if needed |
|
226 | 221 | if newpos > oldpos: |
|
227 | 222 | owrite(self.raw[oldpos:newpos]) |
@@ -248,7 +243,7 b' class Parser:' | |||
|
248 | 243 | |
|
249 | 244 | # send text |
|
250 | 245 | owrite('%s%s%s' % (color,toktext,colors.normal)) |
|
251 | ||
|
246 | ||
|
252 | 247 | def main(argv=None): |
|
253 | 248 | """Run as a command-line script: colorize a python file or stdin using ANSI |
|
254 | 249 | color escapes and print to stdout. |
General Comments 0
You need to be logged in to leave comments.
Login now