diff --git a/html-test/ref/Nesting.html b/html-test/ref/Nesting.html
index 0d6927913d183f49ff408d8a9ffa8133a3acbb79..417876751367b895c286681f4db0f2a5aee2527a 100644
--- a/html-test/ref/Nesting.html
+++ b/html-test/ref/Nesting.html
@@ -166,9 +166,9 @@ the presence of this text pushes it out of nesting back to the top.</li
 	  ><ul
 	    ><li
 	      >Beginning of list<pre
-		> nested
- bird
- tracks</pre
+		>nested
+bird
+tracks</pre
 		></li
 	      ></ul
 	    ></div
@@ -183,9 +183,15 @@ the presence of this text pushes it out of nesting back to the top.</li
 	    ><li
 	      >Beginning of list
 This belongs to the list above!<pre
-		> nested
- bird
- tracks</pre
+		>nested
+bird
+tracks
+
+another line
+  with indentation</pre
+		><pre
+		>nested bird tracks
+  without leading space</pre
 		><ul
 		><li
 		  >Next list
@@ -221,9 +227,9 @@ More of the indented list.<ul
 	      ><dd
 	      >Works for
 definition lists too.<pre
-		> nested
- bird
- tracks</pre
+		>nested
+bird
+tracks</pre
 		><ul
 		><li
 		  >Next list
diff --git a/html-test/ref/SpuriousSuperclassConstraints.html b/html-test/ref/SpuriousSuperclassConstraints.html
index 77e13467b4ebe6a35298579391f29ff5c2c90ba2..171e3d227ff50f0dc62c6c36596be65fb199a532 100644
--- a/html-test/ref/SpuriousSuperclassConstraints.html
+++ b/html-test/ref/SpuriousSuperclassConstraints.html
@@ -63,8 +63,8 @@ window.onload = function () {pageLoad();setSynopsis("mini_SpuriousSuperclassCons
 	  ><p
 	  >It has been fixed in:</p
 	  ><pre
-	  > 6ccf78e15a525282fef61bc4f58a279aa9c21771
- Fix spurious superclass constraints bug.</pre
+	  >6ccf78e15a525282fef61bc4f58a279aa9c21771
+Fix spurious superclass constraints bug.</pre
 	  ></div
 	></div
       ><div id="interface"
diff --git a/html-test/ref/Test.html b/html-test/ref/Test.html
index bd447ea117afae8ccf76b5305ad544b1822352b6..7d229b52461ef12f25fe99c249ba04c27893cad9 100644
--- a/html-test/ref/Test.html
+++ b/html-test/ref/Test.html
@@ -1663,7 +1663,7 @@ using double quotes: <a href=""
                  significant
 </pre
 	    ><pre
-	    > this is another block of code</pre
+	    >this is another block of code</pre
 	    ><p
 	    >We can also include URLs in documentation: <a href=""
 	      >http://www.haskell.org/</a
@@ -1765,17 +1765,17 @@ test2
 	  ></div
 	><div class="doc"
 	><pre
-	  > foo</pre
+	  >foo</pre
 	  ><pre
-	  > bar</pre
+	  >bar</pre
 	  ></div
 	><div class="doc"
 	><p
 	  >This is some inline documentation in the export list</p
 	  ><pre
-	  > a code block using bird-tracks
- each line must begin with &gt; (which isn't significant unless it
- is at the beginning of the line).</pre
+	  >a code block using bird-tracks
+each line must begin with &gt; (which isn't significant unless it
+is at the beginning of the line).</pre
 	  ></div
 	><h1 id="g:7"
 	>A hidden module</h1
@@ -2085,7 +2085,7 @@ test2
 	>A subsection</h2
 	><div class="doc"
 	><pre
-	  > a literal line</pre
+	  >a literal line</pre
 	  ><p
 	  >$ a non <em
 	    >literal</em
diff --git a/html-test/src/Nesting.hs b/html-test/src/Nesting.hs
index 5ab27ec0c8d307d17368062a4384120240a1ff31..34177442c506187043d2b3d992c5cd2570ff6161 100644
--- a/html-test/src/Nesting.hs
+++ b/html-test/src/Nesting.hs
@@ -65,6 +65,12 @@ This belongs to the list above!
     > nested
     > bird
     > tracks
+    >
+    > another line
+    >   with indentation
+
+    >nested bird tracks
+    >  without leading space
 
     * Next list
     More of the indented list.
diff --git a/src/Haddock/Parser.hs b/src/Haddock/Parser.hs
index e9bed2a5b6042498a39554e4b251427ffd8e497b..a6ad817c8abfad42129cc5daecd13a558ee86b89 100644
--- a/src/Haddock/Parser.hs
+++ b/src/Haddock/Parser.hs
@@ -302,10 +302,19 @@ takeNonEmptyLine = do
     (++ "\n") . decodeUtf8 <$> (takeWhile1 (/= '\n') >>= nonSpace) <* "\n"
 
 birdtracks :: Parser (Doc a)
-birdtracks = DocCodeBlock . DocString . intercalate "\n" <$> many1 line
+birdtracks = DocCodeBlock . DocString . intercalate "\n" . stripSpace <$> many1 line
   where
     line = skipHorizontalSpace *> ">" *> takeLine
 
+-- | Strip leading spaces, but ignore blank lines. If any of the lines don't
+--   start with a ' ', however, we don't touch the block.
+stripSpace :: [String] -> [String]
+stripSpace = fromMaybe <*> mapM strip
+  where
+    strip (' ':xs) = Just xs
+    strip "" = Just ""
+    strip _  = Nothing
+
 -- | Parses examples. Examples are a paragraph level entitity (separated by an empty line).
 -- Consecutive examples are accepted.
 examples :: Parser (Doc a)
diff --git a/test/Haddock/ParserSpec.hs b/test/Haddock/ParserSpec.hs
index 455a67f1bff809ac451d1778d6dd2523c25bbff7..ac57b644c0a1a5cdb65344d90596f358d80e43d0 100644
--- a/test/Haddock/ParserSpec.hs
+++ b/test/Haddock/ParserSpec.hs
@@ -360,6 +360,24 @@ spec = before initStaticOpts $ do
           ]
         `shouldParseTo` DocCodeBlock "foo\nbar\nbaz"
 
+      it "ignores single leading spaces" $ do
+        unlines [
+            "> foo"
+          , "> bar"
+          , "> baz"
+          ] `shouldParseTo` DocCodeBlock "foo\nbar\nbaz"
+
+        unlines [
+            "> foo"
+          , ">"
+          , "> bar"
+          ] `shouldParseTo` DocCodeBlock "foo\n\nbar"
+
+        unlines [
+            ">foo"
+          , ">  bar"
+          ] `shouldParseTo` DocCodeBlock "foo\n  bar"
+
       it "ignores nested markup" $ do
         unlines [
             ">/foo/"