hgext/highlight.py
changeset 6494 c30849d4c8ba
parent 6212 e75aab656f46
child 6511 5c1bb5750558
child 6662 22c303a514f8
equal deleted inserted replaced
6493:c19c26718d22 6494:c30849d4c8ba
    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,
    61                                          encoding=util._encoding)
    61                                          encoding=util._encoding)
    62     except ClassNotFound:
    62     except (ClassNotFound, ValueError):
    63         try:
    63         try:
    64             lexer = guess_lexer(text, encoding=util._encoding)
    64             lexer = guess_lexer(text, encoding=util._encoding)
    65         except ClassNotFound:
    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 
    70     colorized = highlight(text, lexer, formatter)
    70     colorized = highlight(text, lexer, formatter)