Mercurial > hg-stable
changeset 6198:358cc9cf54db
highlight: guess by text when path name is ambiguous
Although the docs claim that guess_lexer_for_filename will fall back
to using file data, my ubuntu 7.10 pygments library seems to ignore
the text argument. So call guess_lexer explicitly on failure.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Fri, 29 Feb 2008 14:47:07 -0800 |
parents | f6565f7d9489 |
children | 0068809347d7 |
files | hgext/highlight.py |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/highlight.py Fri Feb 29 14:21:15 2008 -0800 +++ b/hgext/highlight.py Fri Feb 29 14:47:07 2008 -0800 @@ -65,7 +65,10 @@ lexer = guess_lexer_for_filename(fctx.path(), text, encoding=util._encoding) except ClassNotFound: - lexer = TextLexer(encoding=util._encoding) + try: + lexer = guess_lexer(text, encoding=util._encoding) + except ClassNotFound: + lexer = TextLexer(encoding=util._encoding) formatter = HtmlFormatter(style=style, encoding=util._encoding)