@@ -37,8 +37,6 @@ import Data.List ( isPrefixOf, isSuffixOf, drop, intersperse )
3737import Text.PrettyPrint.HughesPJ hiding ( Str )
3838import Control.Monad.State
3939
40−type Notes = [[Block]]
41−type Refs = KeyTable
4240data WriterState =
4341 WriterState { stNotes :: [[Block]]
4442 , stLinks :: KeyTable
@@ -64,9 +62,9 @@ pandocToRST (Pandoc meta blocks) = do
6462 before' = if null before then empty else text before
6563 after' = if null after then empty else text after
6664 metaBlock <- metaToRST opts meta
67− let head = if (writerStandalone opts)
68− then metaBlock $+$ text (writerHeader opts)
69− else empty
65+ let head' = if (writerStandalone opts)
66+ then metaBlock $+$ text (writerHeader opts)
67+ else empty
7068 body <- blockListToRST blocks
7169 includes <- get >>= (return . concat . stIncludes)
7270 let includes' = if null includes then empty else text includes
@@ -74,7 +72,7 @@ pandocToRST (Pandoc meta blocks) = do
7472 -- note that the notes may contain refs, so we do them first
7573 refs <- get >>= (keyTableToRST . reverse . stLinks)
7674 pics <- get >>= (pictTableToRST . reverse . stImages)
77− return $ head $+$ before' $+$ includes' $+$ body $+$ notes $+$ text "" $+$
75+ return $ head' $+$ before' $+$ includes' $+$ body $+$ notes $+$ text "" $+$
7876 refs $+$ pics $+$ after'
7977
8078-- | Return RST representation of reference key table.
@@ -84,7 +82,7 @@ keyTableToRST refs = mapM keyToRST refs >>= return . vcat
8482-- | Return RST representation of a reference key.
8583keyToRST :: ([Inline], (String, String))
8684 -> State WriterState Doc
87−keyToRST (label, (src, tit)) = do
85+keyToRST (label, (src, _)) = do
8886 label' <- inlineListToRST label
8987 let label'' = if ':' `elem` (render label')
9088 then char '`' <> label' <> char '`'
@@ -186,46 +184,39 @@ blockToRST (BlockQuote blocks) = do
186184 tabstop <- get >>= (return . writerTabStop . stOptions)
187185 contents <- blockListToRST blocks
188186 return $ (nest tabstop contents) <> text "\n"
189−blockToRST (Table caption aligns widths headers rows) = do
187+blockToRST (Table caption _ widths headers rows) = do
190188 caption' <- inlineListToRST caption
191189 let caption'' = if null caption
192190 then empty
193191 else text "" $+$ (text "Table: " <> caption')
194192 headers' <- mapM blockListToRST headers
195193 let widthsInChars = map (floor . (78 *)) widths
196− let alignHeader alignment = case alignment of
197− AlignLeft -> leftAlignBlock
198− AlignCenter -> centerAlignBlock
199− AlignRight -> rightAlignBlock
200− AlignDefault -> leftAlignBlock
201194 let hpipeBlocks blocks = hcatBlocks [beg, middle, end]
202195 where height = maximum (map heightOfBlock blocks)
203− sep = TextBlock 3 height (replicate height " | ")
196+ sep' = TextBlock 3 height (replicate height " | ")
204197 beg = TextBlock 2 height (replicate height "| ")
205198 end = TextBlock 2 height (replicate height " |")
206− middle = hcatBlocks $ intersperse sep blocks
199+ middle = hcatBlocks $ intersperse sep' blocks
207200 let makeRow = hpipeBlocks . zipWith docToBlock widthsInChars
208− let head = makeRow headers'
201+ let head' = makeRow headers'
209202 rows' <- mapM (\row -> do cols <- mapM blockListToRST row
210203 return $ makeRow cols) rows
211− let tableWidth = sum widthsInChars
212− let maxRowHeight = maximum $ map heightOfBlock (head:rows')
213204 let border ch = char '+' <> char ch <>
214205 (hcat $ intersperse (char ch <> char '+' <> char ch) $
215206 map (\l -> text $ replicate l ch) widthsInChars) <>
216207 char ch <> char '+'
217208 let body = vcat $ intersperse (border '-') $ map blockToDoc rows'
218− return $ border '-' $+$ blockToDoc head $+$ border '=' $+$ body $+$
209+ return $ border '-' $+$ blockToDoc head' $+$ border '=' $+$ body $+$
219210 border '-' $$ caption'' $$ text ""
220211blockToRST (BulletList items) = do
221212 contents <- mapM bulletListItemToRST items
222213 -- ensure that sublists have preceding blank line
223214 return $ text "" $+$ vcat contents <> text "\n"
224−blockToRST (OrderedList (start, style, delim) items) = do
225− let markers = if start == 1 && style == DefaultStyle && delim == DefaultDelim
215+blockToRST (OrderedList (start, style', delim) items) = do
216+ let markers = if start == 1 && style' == DefaultStyle && delim == DefaultDelim
226217 then take (length items) $ repeat "#."
227218 else take (length items) $ orderedListMarkers
228− (start, style, delim)
219+ (start, style', delim)
229220 let maxMarkerLength = maximum $ map length markers
230221 let markers' = map (\m -> let s = maxMarkerLength - length m
231222 in m ++ replicate s ' ') markers
@@ -254,10 +245,10 @@ orderedListItemToRST marker items = do
254245-- | Convert defintion list item (label, list of blocks) to RST.
255246definitionListItemToRST :: ([Inline], [Block]) -> State WriterState Doc
256247definitionListItemToRST (label, items) = do
257− label <- inlineListToRST label
248+ label' <- inlineListToRST label
258249 contents <- blockListToRST items
259250 tabstop <- get >>= (return . writerTabStop . stOptions)
260− return $ label $+$ nest tabstop contents
251+ return $ label' $+$ nest tabstop contents
261252
262253-- | Convert list of Pandoc block elements to RST.
263254blockListToRST :: [Block] -- ^ List of block elements
@@ -305,13 +296,13 @@ inlineToRST (Math str) = do
305296 then modify $ \st -> st { stIncludes = rawMathRole : includes }
306297 else return ()
307298 return $ text $ ":math:`$" ++ str ++ "$`"
308−inlineToRST (TeX str) = return empty
309−inlineToRST (HtmlInline str) = return empty
299+inlineToRST (TeX _) = return empty
300+inlineToRST (HtmlInline _) = return empty
310301inlineToRST (LineBreak) = do
311302 return $ empty -- there's no line break in RST
312303inlineToRST Space = return $ char ' '
313−inlineToRST (Link [Code str] (src, tit)) | src == str ||
314− src == "mailto:" ++ str = do
304+inlineToRST (Link [Code str] (src, _)) | src == str ||
305+ src == "mailto:" ++ str = do
315306 let srcSuffix = if isPrefixOf "mailto:" src then drop 7 src else src
316307 return $ text srcSuffix
317308inlineToRST (Link txt (src, tit)) = do