highlight: fix page layout with empty first and last lines stable
authorAlexander Plavin <me@aplavin.ru>
Fri, 10 May 2013 00:26:39 +0400
branchstable
changeset 19169 bcdfb6078b9f
parent 19166 e958b17696fe
child 19179 12459bfa4b59
child 19180 12dbdd348bb0
child 19186 36e0260867fb
highlight: fix page layout with empty first and last lines Repeated newlines were stripped by pygmentize, now give the option not to do so.
hgext/highlight/highlight.py
--- 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)