# HG changeset patch
# User Alexander Plavin <me@aplavin.ru>
# Date 1368131199 -14400
#      Fri May 10 00:26:39 2013 +0400
# Branch stable
# Node ID bcdfb6078b9f5bd34982ef8e2287c3837c033d92
# Parent  e958b17696febd17c7bf0c3d5d10c50b764a6374
highlight: fix page layout with empty first and last lines

Repeated newlines were stripped by pygmentize, now give the option not to do so.

diff --git a/hgext/highlight/highlight.py b/hgext/highlight/highlight.py
--- a/hgext/highlight/highlight.py
+++ b/hgext/highlight/highlight.py
@@ -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)