Mercurial > hg
comparison hgext/highlight.py @ 6194:fe54e7501de1
highlight: bail out if file is binary
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Thu, 28 Feb 2008 22:04:22 -0800 |
parents | 2344da8eb9b4 |
children | fc9535ae6fe2 |
comparison
equal
deleted
inserted
replaced
6193:2344da8eb9b4 | 6194:fe54e7501de1 |
---|---|
53 old_header = ''.join(tmpl('header')) | 53 old_header = ''.join(tmpl('header')) |
54 if SYNTAX_CSS not in old_header: | 54 if SYNTAX_CSS not in old_header: |
55 new_header = old_header + SYNTAX_CSS | 55 new_header = old_header + SYNTAX_CSS |
56 tmpl.cache['header'] = new_header | 56 tmpl.cache['header'] = new_header |
57 | 57 |
58 text = fctx.data() | |
59 if util.binary(text): | |
60 return | |
61 | |
58 style = self.config("web", "pygments_style", "colorful") | 62 style = self.config("web", "pygments_style", "colorful") |
59 # To get multi-line strings right, we can't format line-by-line | 63 # To get multi-line strings right, we can't format line-by-line |
60 text = fctx.data() | |
61 try: | 64 try: |
62 lexer = guess_lexer_for_filename(fctx.path(), text, | 65 lexer = guess_lexer_for_filename(fctx.path(), text, |
63 encoding=util._encoding) | 66 encoding=util._encoding) |
64 except ClassNotFound: | 67 except ClassNotFound: |
65 lexer = TextLexer(encoding=util._encoding) | 68 lexer = TextLexer(encoding=util._encoding) |