From b2127311cb360479dbea59264ada0112a94d7819 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Thu, 26 Jun 2014 12:34:41 -0700
Subject: [PATCH] Require haddock-library >= 1.1 and simplify haddock reader
 code.

See #1346.
---
 pandoc.cabal                       |  2 +-
 src/Text/Pandoc/Readers/Haddock.hs | 40 +-----------------------------
 2 files changed, 2 insertions(+), 40 deletions(-)

diff --git a/pandoc.cabal b/pandoc.cabal
index 634d249fe..eeb233d3d 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -259,7 +259,7 @@ Library
                  hslua >= 0.3 && < 0.4,
                  binary >= 0.5 && < 0.8,
                  SHA >= 1.6 && < 1.7,
-                 haddock-library >= 1.0 && < 1.1
+                 haddock-library >= 1.1 && < 1.2
   if flag(https)
      Build-Depends: http-client >= 0.3.2 && < 0.4,
                     http-client-tls >= 0.2 && < 0.3,
diff --git a/src/Text/Pandoc/Readers/Haddock.hs b/src/Text/Pandoc/Readers/Haddock.hs
index a3dfb7c3c..4b46c869d 100644
--- a/src/Text/Pandoc/Readers/Haddock.hs
+++ b/src/Text/Pandoc/Readers/Haddock.hs
@@ -43,11 +43,8 @@ docHToBlocks d' =
             (docHToInlines False $ headerTitle h)
     DocAppend d1 d2 -> mappend (docHToBlocks d1) (docHToBlocks d2)
     DocString _ -> inlineFallback
-    DocParagraph (DocHeader h) -> docHToBlocks (DocHeader h)
     DocParagraph (DocAName h) -> B.plain $ docHToInlines False $ DocAName h
-    DocParagraph x -> let (ils, rest) = getInlines x
-                       in (B.para $ docHToInlines False ils)
-                          <> docHToBlocks rest
+    DocParagraph x -> B.para $ docHToInlines False x
     DocIdentifier _ -> inlineFallback
     DocIdentifierUnchecked _ -> inlineFallback
     DocModule s -> B.plain $ docHToInlines False $ DocModule s
@@ -115,40 +112,6 @@ docHToInlines isCode d' =
     DocProperty _ -> mempty
     DocExamples _ -> mempty
 
-getInlines :: DocH String Identifier -> (DocH String Identifier, DocH String Identifier)
-getInlines (DocAppend x y) = if isInline x
-                                then let (a, b) = getInlines y
-                                     in  (DocAppend x a, b)
-                                else (DocEmpty, DocAppend x y)
-getInlines x = if isInline x
-                  then (x, DocEmpty)
-                  else (DocEmpty, x)
-
-isInline :: DocH String Identifier -> Bool
-isInline d' =
-  case d' of
-    DocEmpty -> True
-    DocAppend d1 _ -> isInline d1
-    DocString _ -> True
-    DocParagraph _ -> False
-    DocIdentifier _ -> True
-    DocIdentifierUnchecked _ -> True
-    DocModule _ -> True
-    DocWarning _ -> True
-    DocEmphasis _ -> True
-    DocMonospaced _ -> True
-    DocBold _ -> True
-    DocHeader _ -> False
-    DocUnorderedList _ -> False
-    DocOrderedList _ -> False
-    DocDefList _ -> False
-    DocCodeBlock _ -> False
-    DocHyperlink _ -> True
-    DocPic _ -> True
-    DocAName _ -> True
-    DocProperty _ -> False
-    DocExamples _ -> False
-
 -- | Create an 'Example', stripping superfluous characters as appropriate
 makeExample :: String -> String -> [String] -> Blocks
 makeExample prompt expression result =
@@ -173,4 +136,3 @@ makeExample prompt expression result =
         substituteBlankLine "<BLANKLINE>" = ""
         substituteBlankLine line          = line
     coder = B.codeWith ([], ["result"], [])
-