hgext/highlight.py
changeset 6662 22c303a514f8
parent 6494 c30849d4c8ba
child 6665 73f49bef13ad
equal deleted inserted replaced
6651:7f0dd352fb4d 6662:22c303a514f8
    55         return
    55         return
    56 
    56 
    57     style = self.config("web", "pygments_style", "colorful")
    57     style = self.config("web", "pygments_style", "colorful")
    58     # To get multi-line strings right, we can't format line-by-line
    58     # To get multi-line strings right, we can't format line-by-line
    59     try:
    59     try:
    60         lexer = guess_lexer_for_filename(fctx.path(), text,
    60         lexer = guess_lexer_for_filename(fctx.path(), text[:1024],
    61                                          encoding=util._encoding)
    61                                          encoding=util._encoding)
    62     except (ClassNotFound, ValueError):
    62     except (ClassNotFound, ValueError):
    63         try:
    63         try:
    64             lexer = guess_lexer(text, encoding=util._encoding)
    64             lexer = guess_lexer(text[:1024], encoding=util._encoding)
    65         except (ClassNotFound, ValueError):
    65         except (ClassNotFound, ValueError):
    66             lexer = TextLexer(encoding=util._encoding)
    66             lexer = TextLexer(encoding=util._encoding)
    67 
    67 
    68     formatter = HtmlFormatter(style=style, encoding=util._encoding)
    68     formatter = HtmlFormatter(style=style, encoding=util._encoding)
    69 
    69