Show More
@@ -192,7 +192,10 b' class DiffProcessor(object):' | |||||
192 | """, re.VERBOSE | re.MULTILINE) |
|
192 | """, re.VERBOSE | re.MULTILINE) | |
193 |
|
193 | |||
194 | #used for inline highlighter word split |
|
194 | #used for inline highlighter word split | |
195 | _token_re = re.compile(r'()(>|<|&|\W+?)') |
|
195 | _token_re = re.compile(r'()(>|<|&|<u>\t</u>| <i></i>|\W+?)') | |
|
196 | ||||
|
197 | _escape_re = re.compile(r'(&)|(<)|(>)|(\t)|( \n| $)') | |||
|
198 | ||||
196 |
|
199 | |||
197 | def __init__(self, diff, vcs='hg', format='gitdiff', diff_limit=None): |
|
200 | def __init__(self, diff, vcs='hg', format='gitdiff', diff_limit=None): | |
198 | """ |
|
201 | """ | |
@@ -248,9 +251,20 b' class DiffProcessor(object):' | |||||
248 | if self.diff_limit is not None and self.cur_diff_size > self.diff_limit: |
|
251 | if self.diff_limit is not None and self.cur_diff_size > self.diff_limit: | |
249 | raise DiffLimitExceeded('Diff Limit Exceeded') |
|
252 | raise DiffLimitExceeded('Diff Limit Exceeded') | |
250 |
|
253 | |||
251 | return safe_unicode(string).replace('&', '&')\ |
|
254 | def substitute(m): | |
252 | .replace('<', '<')\ |
|
255 | groups = m.groups() | |
253 | .replace('>', '>') |
|
256 | if groups[0]: | |
|
257 | return '&' | |||
|
258 | if groups[1]: | |||
|
259 | return '<' | |||
|
260 | if groups[2]: | |||
|
261 | return '>' | |||
|
262 | if groups[3]: | |||
|
263 | return '<u>\t</u>' | |||
|
264 | if groups[4] and m.start(): # skip 1st column with +/- | |||
|
265 | return ' <i></i>' | |||
|
266 | ||||
|
267 | return self._escape_re.sub(substitute, safe_unicode(string)) | |||
254 |
|
268 | |||
255 | def _line_counter(self, l): |
|
269 | def _line_counter(self, l): | |
256 | """ |
|
270 | """ |
@@ -266,6 +266,18 b' class CodeHtmlFormatter(HtmlFormatter):' | |||||
266 | yield 0, '</td></tr></table>' |
|
266 | yield 0, '</td></tr></table>' | |
267 |
|
267 | |||
268 |
|
268 | |||
|
269 | _whitespace_re = re.compile(r'(\t)|( )(?=\n|</div>)') | |||
|
270 | ||||
|
271 | def _markup_whitespace(m): | |||
|
272 | groups = m.groups() | |||
|
273 | if groups[0]: | |||
|
274 | return '<u>\t</u>' | |||
|
275 | if groups[1]: | |||
|
276 | return ' <i></i>' | |||
|
277 | ||||
|
278 | def markup_whitespace(s): | |||
|
279 | return _whitespace_re.sub(_markup_whitespace, s) | |||
|
280 | ||||
269 | def pygmentize(filenode, **kwargs): |
|
281 | def pygmentize(filenode, **kwargs): | |
270 | """ |
|
282 | """ | |
271 | pygmentize function using pygments |
|
283 | pygmentize function using pygments | |
@@ -273,8 +285,8 b' def pygmentize(filenode, **kwargs):' | |||||
273 | :param filenode: |
|
285 | :param filenode: | |
274 | """ |
|
286 | """ | |
275 | lexer = get_custom_lexer(filenode.extension) or filenode.lexer |
|
287 | lexer = get_custom_lexer(filenode.extension) or filenode.lexer | |
276 | return literal(code_highlight(filenode.content, lexer, |
|
288 | return literal(markup_whitespace( | |
277 | CodeHtmlFormatter(**kwargs))) |
|
289 | code_highlight(filenode.content, lexer, CodeHtmlFormatter(**kwargs)))) | |
278 |
|
290 | |||
279 |
|
291 | |||
280 | def pygmentize_annotation(repo_name, filenode, **kwargs): |
|
292 | def pygmentize_annotation(repo_name, filenode, **kwargs): | |
@@ -361,7 +373,7 b' def pygmentize_annotation(repo_name, fil' | |||||
361 | return uri |
|
373 | return uri | |
362 | return _url_func |
|
374 | return _url_func | |
363 |
|
375 | |||
364 | return literal(annotate_highlight(filenode, url_func(repo_name), **kwargs)) |
|
376 | return literal(markup_whitespace(annotate_highlight(filenode, url_func(repo_name), **kwargs))) | |
365 |
|
377 | |||
366 |
|
378 | |||
367 | def is_following_repo(repo_name, user_id): |
|
379 | def is_following_repo(repo_name, user_id): |
@@ -4974,6 +4974,23 b' table.code-difftable .del del {' | |||||
4974 | text-decoration: none; |
|
4974 | text-decoration: none; | |
4975 | } |
|
4975 | } | |
4976 |
|
4976 | |||
|
4977 | table.code-highlighttable div.code-highlight pre u:before, | |||
|
4978 | table.code-difftable td.code pre u:before { | |||
|
4979 | content: "\21a6"; | |||
|
4980 | display: inline-block; | |||
|
4981 | width: 0; | |||
|
4982 | } | |||
|
4983 | table.code-highlighttable div.code-highlight pre u, | |||
|
4984 | table.code-difftable td.code pre u { | |||
|
4985 | color: rgba(0,0,0,0.15); | |||
|
4986 | } | |||
|
4987 | table.code-highlighttable div.code-highlight pre i, | |||
|
4988 | table.code-difftable td.code pre i { | |||
|
4989 | border-style: solid; | |||
|
4990 | border-left-width: 1px; | |||
|
4991 | color: rgba(0,0,0,0.15); | |||
|
4992 | } | |||
|
4993 | ||||
4977 | /** LINE NUMBERS **/ |
|
4994 | /** LINE NUMBERS **/ | |
4978 | table.code-difftable .lineno { |
|
4995 | table.code-difftable .lineno { | |
4979 | padding-left: 2px; |
|
4996 | padding-left: 2px; |
General Comments 0
You need to be logged in to leave comments.
Login now