changeset 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 e958b17696fe
children 12459bfa4b59 12dbdd348bb0 36e0260867fb
files hgext/highlight/highlight.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
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)