highlight: bail out if file is binary
authorBrendan Cully <brendan@kublai.com>
Thu, 28 Feb 2008 22:04:22 -0800
changeset 6194 fe54e7501de1
parent 6193 2344da8eb9b4
child 6195 272fd5fa576d
highlight: bail out if file is binary
hgext/highlight.py
--- a/hgext/highlight.py	Thu Feb 28 21:35:27 2008 -0800
+++ b/hgext/highlight.py	Thu Feb 28 22:04:22 2008 -0800
@@ -55,9 +55,12 @@
         new_header =  old_header + SYNTAX_CSS
         tmpl.cache['header'] = new_header
 
+    text = fctx.data()
+    if util.binary(text):
+        return
+
     style = self.config("web", "pygments_style", "colorful")
     # To get multi-line strings right, we can't format line-by-line
-    text = fctx.data()
     try:
         lexer = guess_lexer_for_filename(fctx.path(), text,
                                          encoding=util._encoding)