From fad8d0d67ff4736e1af554d2bfcf1688aa28c8ec Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Fri, 16 Mar 2018 23:18:42 -0700
Subject: [PATCH] Allow earlier versions of haddock-library, use CPP.

---
 pandoc.cabal                       | 2 +-
 src/Text/Pandoc/Readers/Haddock.hs | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/pandoc.cabal b/pandoc.cabal
index 269bb99d5..e231c1541 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -388,7 +388,7 @@ library
                  hslua-module-text >= 0.1.2 && < 0.2,
                  binary >= 0.5 && < 0.10,
                  SHA >= 1.6 && < 1.7,
-                 haddock-library >= 1.5 && < 1.6,
+                 haddock-library >= 1.1 && < 1.6,
                  deepseq >= 1.3 && < 1.5,
                  JuicyPixels >= 3.1.6.1 && < 3.3,
                  Glob >= 0.7 && < 0.10,
diff --git a/src/Text/Pandoc/Readers/Haddock.hs b/src/Text/Pandoc/Readers/Haddock.hs
index b593c4cc8..d3531dd03 100644
--- a/src/Text/Pandoc/Readers/Haddock.hs
+++ b/src/Text/Pandoc/Readers/Haddock.hs
@@ -85,6 +85,7 @@ docHToBlocks d' =
     DocProperty s -> B.codeBlockWith ("",["property","haskell"],[]) (trim s)
     DocExamples es -> mconcat $ map (\e ->
        makeExample ">>>" (exampleExpression e) (exampleResult e)) es
+#if MIN_VERSION_haddock_library(1,5,0)
     DocTable H.Table{ tableHeaderRows = headerRows
                     , tableBodyRows = bodyRows
                     }
@@ -97,6 +98,7 @@ docHToBlocks d' =
              colspecs = replicate (maximum (map length body))
                              (AlignDefault, 0.0)
          in  B.table mempty colspecs header body
+#endif
 
   where inlineFallback = B.plain $ docHToInlines False d'
         consolidatePlains = B.fromList . consolidatePlains' . B.toList