@@ -44,7 +44,13 @@ readHaddockEither :: ReaderOptions -- ^ Reader options
44 -> String -- ^ String to parse
44 -> String -- ^ String to parse
45 -> Either PandocError Pandoc
45 -> Either PandocError Pandoc
46readHaddockEither _opts =
46readHaddockEither _opts =
47+#if MIN_VERSION_haddock_library(1,6,0)
47 Right . B.doc . docHToBlocks . _doc . parseParas Nothing
48 Right . B.doc . docHToBlocks . _doc . parseParas Nothing
49+#elif MIN_VERSION_haddock_library(1,2,0)
50+ Right . B.doc . docHToBlocks . _doc . parseParas
52+ Right . B.doc . docHToBlocks . parseParas
49docHToBlocks :: DocH String Identifier -> Blocks
55docHToBlocks :: DocH String Identifier -> Blocks
50docHToBlocks d' =
56docHToBlocks d' =
@@ -64,8 +70,10 @@ docHToBlocks d' =
64 DocEmphasis _ -> inlineFallback
70 DocEmphasis _ -> inlineFallback
65 DocMonospaced _ -> inlineFallback
71 DocMonospaced _ -> inlineFallback
66 DocBold _ -> inlineFallback
72 DocBold _ -> inlineFallback
73+#if MIN_VERSION_haddock_library(1,4,0)
67 DocMathInline _ -> inlineFallback
74 DocMathInline _ -> inlineFallback
68 DocMathDisplay _ -> inlineFallback
75 DocMathDisplay _ -> inlineFallback
69 DocHeader h -> B.header (headerLevel h)
77 DocHeader h -> B.header (headerLevel h)
70 (docHToInlines False $ headerTitle h)
78 (docHToInlines False $ headerTitle h)
71 DocUnorderedList items -> B.bulletList (map docHToBlocks items)
79 DocUnorderedList items -> B.bulletList (map docHToBlocks items)
@@ -81,6 +89,7 @@ docHToBlocks d' =
81 DocProperty s -> B.codeBlockWith ("",["property","haskell"],[]) (trim s)
89 DocProperty s -> B.codeBlockWith ("",["property","haskell"],[]) (trim s)
82 DocExamples es -> mconcat $ map (\e ->
90 DocExamples es -> mconcat $ map (\e ->
83 makeExample ">>>" (exampleExpression e) (exampleResult e)) es
91 makeExample ">>>" (exampleExpression e) (exampleResult e)) es
92+#if MIN_VERSION_haddock_library(1,5,0)
84 DocTable H.Table{ tableHeaderRows = headerRows
93 DocTable H.Table{ tableHeaderRows = headerRows
85 , tableBodyRows = bodyRows
94 , tableBodyRows = bodyRows
@@ -93,7 +102,7 @@ docHToBlocks d' =
93 colspecs = replicate (maximum (map length body))
102 colspecs = replicate (maximum (map length body))
94 (AlignDefault, 0.0)
103 (AlignDefault, 0.0)
95 in B.table mempty colspecs header body
104 in B.table mempty colspecs header body
97 where inlineFallback = B.plain $ docHToInlines False d'
106 where inlineFallback = B.plain $ docHToInlines False d'
98 consolidatePlains = B.fromList . consolidatePlains' . B.toList
107 consolidatePlains = B.fromList . consolidatePlains' . B.toList
99 consolidatePlains' zs@(Plain _ : _) =
108 consolidatePlains' zs@(Plain _ : _) =
@@ -125,8 +134,10 @@ docHToInlines isCode d' =
125 DocMonospaced (DocString s) -> B.code s
134 DocMonospaced (DocString s) -> B.code s
126 DocMonospaced d -> docHToInlines True d
135 DocMonospaced d -> docHToInlines True d
127 DocBold d -> B.strong (docHToInlines isCode d)
136 DocBold d -> B.strong (docHToInlines isCode d)
137+#if MIN_VERSION_haddock_library(1,4,0)
128 DocMathInline s -> B.math s
138 DocMathInline s -> B.math s
129 DocMathDisplay s -> B.displayMath s
139 DocMathDisplay s -> B.displayMath s
130 DocHeader _ -> mempty
141 DocHeader _ -> mempty
131 DocUnorderedList _ -> mempty
142 DocUnorderedList _ -> mempty
132 DocOrderedList _ -> mempty
143 DocOrderedList _ -> mempty
@@ -139,7 +150,9 @@ docHToInlines isCode d' =
139 DocAName s -> B.spanWith (s,["anchor"],[]) mempty
150 DocAName s -> B.spanWith (s,["anchor"],[]) mempty
140 DocProperty _ -> mempty
151 DocProperty _ -> mempty
141 DocExamples _ -> mempty
152 DocExamples _ -> mempty
153+#if MIN_VERSION_haddock_library(1,5,0)
142 DocTable _ -> mempty
154 DocTable _ -> mempty
144-- | Create an 'Example', stripping superfluous characters as appropriate
157-- | Create an 'Example', stripping superfluous characters as appropriate
145makeExample :: String -> String -> [String] -> Blocks
158makeExample :: String -> String -> [String] -> Blocks