@@ -44,7 +44,13 @@ readHaddockEither :: ReaderOptions -- ^ Reader options
4444 -> String -- ^ String to parse
4545 -> Either PandocError Pandoc
4646readHaddockEither _opts =
47+#if MIN_VERSION_haddock_library(1,6,0)
4748 Right . B.doc . docHToBlocks . _doc . parseParas Nothing
49+#elif MIN_VERSION_haddock_library(1,2,0)
50+ Right . B.doc . docHToBlocks . _doc . parseParas
51+#else
52+ Right . B.doc . docHToBlocks . parseParas
53+#endif
4854
4955docHToBlocks :: DocH String Identifier -> Blocks
5056docHToBlocks d' =
@@ -64,8 +70,10 @@ docHToBlocks d' =
6470 DocEmphasis _ -> inlineFallback
6571 DocMonospaced _ -> inlineFallback
6672 DocBold _ -> inlineFallback
73+#if MIN_VERSION_haddock_library(1,4,0)
6774 DocMathInline _ -> inlineFallback
6875 DocMathDisplay _ -> inlineFallback
76+#endif
6977 DocHeader h -> B.header (headerLevel h)
7078 (docHToInlines False $ headerTitle h)
7179 DocUnorderedList items -> B.bulletList (map docHToBlocks items)
@@ -81,6 +89,7 @@ docHToBlocks d' =
8189 DocProperty s -> B.codeBlockWith ("",["property","haskell"],[]) (trim s)
8290 DocExamples es -> mconcat $ map (\e ->
8391 makeExample ">>>" (exampleExpression e) (exampleResult e)) es
92+#if MIN_VERSION_haddock_library(1,5,0)
8493 DocTable H.Table{ tableHeaderRows = headerRows
8594 , tableBodyRows = bodyRows
8695 }
@@ -93,7 +102,7 @@ docHToBlocks d' =
93102 colspecs = replicate (maximum (map length body))
94103 (AlignDefault, 0.0)
95104 in B.table mempty colspecs header body
96−
105+#endif
97106 where inlineFallback = B.plain $ docHToInlines False d'
98107 consolidatePlains = B.fromList . consolidatePlains' . B.toList
99108 consolidatePlains' zs@(Plain _ : _) =
@@ -125,8 +134,10 @@ docHToInlines isCode d' =
125134 DocMonospaced (DocString s) -> B.code s
126135 DocMonospaced d -> docHToInlines True d
127136 DocBold d -> B.strong (docHToInlines isCode d)
137+#if MIN_VERSION_haddock_library(1,4,0)
128138 DocMathInline s -> B.math s
129139 DocMathDisplay s -> B.displayMath s
140+#endif
130141 DocHeader _ -> mempty
131142 DocUnorderedList _ -> mempty
132143 DocOrderedList _ -> mempty
@@ -139,7 +150,9 @@ docHToInlines isCode d' =
139150 DocAName s -> B.spanWith (s,["anchor"],[]) mempty
140151 DocProperty _ -> mempty
141152 DocExamples _ -> mempty
153+#if MIN_VERSION_haddock_library(1,5,0)
142154 DocTable _ -> mempty
155+#endif
143156
144157-- | Create an 'Example', stripping superfluous characters as appropriate
145158makeExample :: String -> String -> [String] -> Blocks