Patchwork highlight: fix page layout with empty first and last lines

login
register
mail settings
Submitter Alexander Plavin
Date May 9, 2013, 8:27 p.m.
Message ID <c865494372d291b6afbe.1368131234@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1603/
State Superseded
Commit bcdfb6078b9f5bd34982ef8e2287c3837c033d92
Headers show

Comments

Alexander Plavin - May 9, 2013, 8:27 p.m.
# HG changeset patch
# User Alexander Plavin <me@aplavin.ru>
# Date 1368131199 -14400
#      Fri May 10 00:26:39 2013 +0400
# Node ID c865494372d291b6afbe7c3ed2d196f79f02aa5c
# 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.
Matt Mackall - May 9, 2013, 9:22 p.m.
On Fri, 2013-05-10 at 00:27 +0400, Alexander Plavin wrote:
> # HG changeset patch
> # User Alexander Plavin <me@aplavin.ru>
> # Date 1368131199 -14400
> #      Fri May 10 00:26:39 2013 +0400
> # Node ID c865494372d291b6afbe7c3ed2d196f79f02aa5c
> # 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.

Queued for stable after fixing up check-code complaints, thanks. Please
use --flag stable for bugfixes.

Patch

diff -r f6109ee404d5 -r c865494372d2 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,12 @@ 
 
     # 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)