Mercurial > public > mercurial-scm > hg-stable
diff hgext/highlight/highlight.py @ 19169:bcdfb6078b9f stable
highlight: fix page layout with empty first and last lines
Repeated newlines were stripped by pygmentize, now give the option not to do so.
author | Alexander Plavin <me@aplavin.ru> |
---|---|
date | Fri, 10 May 2013 00:26:39 +0400 |
parents | b35e3364f94a |
children | 7b8ff3fd11d3 |
line wrap: on
line diff
--- a/hgext/highlight/highlight.py Thu May 09 15:17:29 2013 -0500 +++ b/hgext/highlight/highlight.py Fri May 10 00:26:39 2013 +0400 @@ -38,12 +38,13 @@ # To get multi-line strings right, we can't format line-by-line try: - lexer = guess_lexer_for_filename(fctx.path(), text[:1024]) + lexer = guess_lexer_for_filename(fctx.path(), text[:1024], + stripnl=False) except (ClassNotFound, ValueError): try: - lexer = guess_lexer(text[:1024]) + lexer = guess_lexer(text[:1024], stripnl=False) except (ClassNotFound, ValueError): - lexer = TextLexer() + lexer = TextLexer(stripnl=False) formatter = HtmlFormatter(style=style)