[PATCH V2] highlight: fix page layout with empty first and last lines

Alexander Plavin me at aplavin.ru
Thu May 9 16:01:23 CDT 2013


# HG changeset patch
# User Alexander Plavin <me at aplavin.ru>
# Date 1368131199 -14400
#      Fri May 10 00:26:39 2013 +0400
# Node ID f1d570befd2617cfd5918a5b055b782386b96ad4
# Parent  f6109ee404d5b510dd41d1f6edadb6cbd14430b5
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 -r f6109ee404d5 -r f1d570befd26 hgext/highlight/highlight.py
--- a/hgext/highlight/highlight.py	Thu May 09 10:51:03 2013 -0500
+++ b/hgext/highlight/highlight.py	Fri May 10 00:26:39 2013 +0400
@@ -38,12 +38,15 @@
 
     # 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)
 


More information about the Mercurial-devel mailing list