diff --git a/hgext/highlight/highlight.py b/hgext/highlight/highlight.py
index e958b17696febd17c7bf0c3d5d10c50b764a6374_aGdleHQvaGlnaGxpZ2h0L2hpZ2hsaWdodC5weQ==..bcdfb6078b9f5bd34982ef8e2287c3837c033d92_aGdleHQvaGlnaGxpZ2h0L2hpZ2hsaWdodC5weQ== 100644
--- a/hgext/highlight/highlight.py
+++ b/hgext/highlight/highlight.py
@@ -38,6 +38,7 @@
 
     # 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:
@@ -42,4 +43,4 @@
     except (ClassNotFound, ValueError):
         try:
-            lexer = guess_lexer(text[:1024])
+            lexer = guess_lexer(text[:1024], stripnl=False)
         except (ClassNotFound, ValueError):
@@ -45,5 +46,5 @@
         except (ClassNotFound, ValueError):
-            lexer = TextLexer()
+            lexer = TextLexer(stripnl=False)
 
     formatter = HtmlFormatter(style=style)