git.iko.soy/typeable/pandoc
on master help sign in
Code cleanup in markdown writer to eliminate -Wall warnings.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1310 788f1e2b-df1e-0410-8736-df70ead52e1b

commitea31c82dbdd3d7245e795b682b1cabe603ffcf1f authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSun 13 Jul 2008, 23:10 (18 years ago) parente9dc5aa
1 file changed+24−25
Text/Pandoc/Writers/Markdown.hs+24−25
Text/Pandoc/Writers/Markdown.hs+24−25
@@ -55,7 +55,7 @@ pandocToMarkdown opts (Pandoc meta blocks) = do
5555 let before' = if null before then empty else text before
5656 let after' = if null after then empty else text after
5757 metaBlock <- metaToMarkdown opts meta
58− let head = if writerStandalone opts
58+ let head' = if writerStandalone opts
5959 then metaBlock $+$ text (writerHeader opts)
6060 else empty
6161 let headerBlocks = filter isHeaderBlock blocks
@@ -67,7 +67,7 @@ pandocToMarkdown opts (Pandoc meta blocks) = do
6767 notes' <- notesToMarkdown opts (reverse notes)
6868 (_, refs) <- get -- note that the notes may contain refs
6969 refs' <- keyTableToMarkdown opts (reverse refs)
70− return $ head $+$ before' $+$ toc $+$ body $+$ text "" $+$
70+ return $ head' $+$ before' $+$ toc $+$ body $+$ text "" $+$
7171 notes' $+$ text "" $+$ refs' $+$ after'
7272
7373-- | Return markdown representation of reference key table.
@@ -111,7 +111,7 @@ metaToMarkdown opts (Meta title authors date) = do
111111 return $ title' $+$ authors' $+$ date'
112112
113113titleToMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc
114−titleToMarkdown opts [] = return empty
114+titleToMarkdown _ [] = return empty
115115titleToMarkdown opts lst = do
116116 contents <- inlineListToMarkdown opts lst
117117 return $ text "% " <> contents
@@ -142,9 +142,9 @@ elementToListItem (Sec headerText subsecs) = [Plain headerText] ++
142142
143143-- | Ordered list start parser for use in Para below.
144144olMarker :: GenParser Char st Char
145−olMarker = do (start, style, delim) <- anyOrderedListMarker
145+olMarker = do (start, style', delim) <- anyOrderedListMarker
146146 if delim == Period &&
147− (style == UpperAlpha || (style == UpperRoman &&
147+ (style' == UpperAlpha || (style' == UpperRoman &&
148148 start `elem` [1, 5, 10, 50, 100, 500, 1000]))
149149 then spaceChar >> spaceChar
150150 else spaceChar
@@ -169,7 +169,7 @@ wrappedMarkdown opts inlines = do
169169blockToMarkdown :: WriterOptions -- ^ Options
170170 -> Block -- ^ Block element
171171 -> State WriterState Doc
172−blockToMarkdown opts Null = return empty
172+blockToMarkdown _ Null = return empty
173173blockToMarkdown opts (Plain inlines) =
174174 wrappedMarkdown opts inlines
175175blockToMarkdown opts (Para inlines) = do
@@ -180,8 +180,8 @@ blockToMarkdown opts (Para inlines) = do
180180 then char '\\'
181181 else empty
182182 return $ esc <> contents <> text "\n"
183−blockToMarkdown opts (RawHtml str) = return $ text str
184−blockToMarkdown opts HorizontalRule = return $ text "\n* * * * *\n"
183+blockToMarkdown _ (RawHtml str) = return $ text str
184+blockToMarkdown _ HorizontalRule = return $ text "\n* * * * *\n"
185185blockToMarkdown opts (Header level inlines) = do
186186 contents <- inlineListToMarkdown opts inlines
187187 return $ text ((replicate level '#') ++ " ") <> contents <> text "\n"
@@ -205,11 +205,10 @@ blockToMarkdown opts (Table caption aligns widths headers rows) = do
205205 AlignDefault -> leftAlignBlock
206206 let makeRow = hsepBlocks . (zipWith alignHeader aligns) .
207207 (zipWith docToBlock widthsInChars)
208− let head = makeRow headers'
208+ let head' = makeRow headers'
209209 rows' <- mapM (\row -> do cols <- mapM (blockListToMarkdown opts) row
210210 return $ makeRow cols) rows
211− let tableWidth = sum widthsInChars
212− let maxRowHeight = maximum $ map heightOfBlock (head:rows')
211+ let maxRowHeight = maximum $ map heightOfBlock (head':rows')
213212 let isMultilineTable = maxRowHeight > 1
214213 let underline = hsep $
215214 map (\width -> text $ replicate width '-') widthsInChars
@@ -220,7 +219,7 @@ blockToMarkdown opts (Table caption aligns widths headers rows) = do
220219 then text ""
221220 else empty
222221 let body = vcat $ intersperse spacer $ map blockToDoc rows'
223− return $ (nest 2 $ border $+$ (blockToDoc head) $+$ underline $+$ body $+$
222+ return $ (nest 2 $ border $+$ (blockToDoc head') $+$ underline $+$ body $+$
224223 border $+$ caption'') <> text "\n"
225224blockToMarkdown opts (BulletList items) = do
226225 contents <- mapM (bulletListItemToMarkdown opts) items
@@ -291,7 +290,7 @@ getReference label (src, tit) = do
291290 Just x -> [Str (show x)]
292291 Nothing -> error "no unique label"
293292 Nothing -> label
294− modify (\(notes, refs) -> (notes, (label', (src,tit)):refs))
293+ modify (\(notes, refs') -> (notes, (label', (src,tit)):refs'))
295294 return label'
296295
297296-- | Convert list of Pandoc inline elements to markdown.
@@ -324,11 +323,11 @@ inlineToMarkdown opts (Quoted SingleQuote lst) = do
324323inlineToMarkdown opts (Quoted DoubleQuote lst) = do
325324 contents <- inlineListToMarkdown opts lst
326325 return $ char '"' <> contents <> char '"'
327−inlineToMarkdown opts EmDash = return $ text "--"
328−inlineToMarkdown opts EnDash = return $ char '-'
329−inlineToMarkdown opts Apostrophe = return $ char '\''
330−inlineToMarkdown opts Ellipses = return $ text "..."
331−inlineToMarkdown opts (Code str) =
326+inlineToMarkdown _ EmDash = return $ text "--"
327+inlineToMarkdown _ EnDash = return $ char '-'
328+inlineToMarkdown _ Apostrophe = return $ char '\''
329+inlineToMarkdown _ Ellipses = return $ text "..."
330+inlineToMarkdown _ (Code str) =
332331 let tickGroups = filter (\s -> '`' `elem` s) $ group str
333332 longest = if null tickGroups
334333 then 0
@@ -336,12 +335,12 @@ inlineToMarkdown opts (Code str) =
336335 marker = replicate (longest + 1) '`'
337336 spacer = if (longest == 0) then "" else " " in
338337 return $ text (marker ++ spacer ++ str ++ spacer ++ marker)
339−inlineToMarkdown opts (Str str) = return $ text $ escapeString str
340−inlineToMarkdown opts (Math str) = return $ char '$' <> text str <> char '$'
341−inlineToMarkdown opts (TeX str) = return $ text str
342−inlineToMarkdown opts (HtmlInline str) = return $ text str
343−inlineToMarkdown opts (LineBreak) = return $ text " \n"
344−inlineToMarkdown opts Space = return $ char ' '
338+inlineToMarkdown _ (Str str) = return $ text $ escapeString str
339+inlineToMarkdown _ (Math str) = return $ char '$' <> text str <> char '$'
340+inlineToMarkdown _ (TeX str) = return $ text str
341+inlineToMarkdown _ (HtmlInline str) = return $ text str
342+inlineToMarkdown _ (LineBreak) = return $ text " \n"
343+inlineToMarkdown _ Space = return $ char ' '
345344inlineToMarkdown opts (Link txt (src, tit)) = do
346345 linktext <- inlineListToMarkdown opts txt
347346 let linktitle = if null tit then empty else text $ " \"" ++ tit ++ "\""
@@ -367,7 +366,7 @@ inlineToMarkdown opts (Image alternate (source, tit)) = do
367366 else alternate
368367 linkPart <- inlineToMarkdown opts (Link txt (source, tit))
369368 return $ char '!' <> linkPart
370−inlineToMarkdown opts (Note contents) = do
369+inlineToMarkdown _ (Note contents) = do
371370 modify (\(notes, refs) -> (contents:notes, refs)) -- add to notes in state
372371 (notes, _) <- get
373372 let ref = show $ (length notes)