@@ -49,7 +49,7 @@ import Text.CSL
4949import Text.Pandoc.Biblio
5050#endif
5151import Text.Pandoc.Plugins (getPlugin)
52−import Control.Monad (foldM)
52+import Control.Monad (foldM, when, unless)
5353
5454copyrightMessage :: String
5555copyrightMessage = "\nCopyright (C) 2006-8 John MacFarlane\n" ++
@@ -98,7 +98,7 @@ readers = [("native" , readPandoc)
9898
9999-- | Reader for native Pandoc format.
100100readPandoc :: ParserState -> String -> Pandoc
101−readPandoc _ input = read input
101+readPandoc _ = read
102102
103103-- | Association list of formats and pairs of writers and default headers.
104104writers :: [ ( String, ( WriterOptions -> Pandoc -> String, String ) ) ]
@@ -440,11 +440,10 @@ options =
440440
441441-- Returns usage message
442442usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
443−usageMessage programName opts = usageInfo
443+usageMessage programName = usageInfo
444444 (programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++
445445 (intercalate ", " $ map fst readers) ++ "\nOutput formats: " ++
446446 (intercalate ", " $ map fst writers) ++ "\nOptions:")
447− opts
448447
449448-- Determine default reader based on source file extensions
450449defaultReaderName :: [FilePath] -> String
@@ -505,14 +504,11 @@ main = do
505504 then ([], rawArgs, [])
506505 else getOpt Permute options rawArgs
507506
508− if (not (null errors))
509− then do
510− name <- getProgName
511− mapM (\e -> hPutStrLn stderr e) errors
512− hPutStr stderr (usageMessage name options)
513− exitWith $ ExitFailure 2
514− else
515− return ()
507+ unless (null errors) $
508+ do name <- getProgName
509+ mapM_ (\e -> hPutStrLn stderr e) errors
510+ hPutStr stderr (usageMessage name options)
511+ exitWith $ ExitFailure 2
516512
517513 let defaultOpts' = if compatMode
518514 then defaultOpts { optReader = "markdown"
@@ -556,12 +552,10 @@ main = do
556552#endif
557553 } = opts
558554
559− if dumpArgs
560− then do
561− hPutStrLn stdout outputFile
562− mapM (\arg -> hPutStrLn stdout arg) args
563− exitWith $ ExitSuccess
564− else return ()
555+ when dumpArgs $
556+ do hPutStrLn stdout outputFile
557+ mapM_ (\arg -> hPutStrLn stdout arg) args
558+ exitWith ExitSuccess
565559
566560 let sources = if ignoreArgs then [] else args
567561
@@ -588,18 +582,18 @@ main = do
588582 Nothing -> stateColumns defaultParserState
589583
590584 let tabFilter _ [] = ""
591− tabFilter _ ('\n':xs) = '\n':(tabFilter tabStop xs)
585+ tabFilter _ ('\n':xs) = '\n' : tabFilter tabStop xs
592586 -- remove DOS line endings
593− tabFilter _ ('\r':'\n':xs) = '\n':(tabFilter tabStop xs)
594− tabFilter _ ('\r':xs) = '\n':(tabFilter tabStop xs)
587+ tabFilter _ ('\r':'\n':xs) = '\n' : tabFilter tabStop xs
588+ tabFilter _ ('\r':xs) = '\n' : tabFilter tabStop xs
595589 tabFilter spsToNextStop ('\t':xs) =
596590 if preserveTabs
597− then '\t':(tabFilter tabStop xs)
591+ then '\t' : tabFilter tabStop xs
598592 else replicate spsToNextStop ' ' ++ tabFilter tabStop xs
599593 tabFilter 1 (x:xs) =
600− x:(tabFilter tabStop xs)
594+ x : tabFilter tabStop xs
601595 tabFilter spsToNextStop (x:xs) =
602− x:(tabFilter (spsToNextStop - 1) xs)
596+ x : tabFilter (spsToNextStop - 1) xs
603597
604598 let standalone' = (standalone && not strict) || isNonTextOutput writerName'
605599
@@ -627,7 +621,7 @@ main = do
627621 (\f -> "<link rel=\"stylesheet\" href=\"" ++
628622 f ++ "\" type=\"text/css\" media=\"all\" />\n")
629623 css
630− let header = (if (customHeader == "DEFAULT")
624+ let header = (if customHeader == "DEFAULT"
631625 then defaultHeader
632626 else customHeader) ++ csslink ++ includeHeader
633627 let writerOptions = WriterOptions { writerStandalone = standalone',
@@ -635,7 +629,7 @@ main = do
635629 writerTitlePrefix = titlePrefix,
636630 writerTabStop = tabStop,
637631 writerTableOfContents = toc &&
638− (not strict) &&
632+ not strict &&
639633 writerName' /= "s5",
640634 writerHTMLMathMethod = mathMethod,
641635 writerS5 = (writerName' == "s5"),
@@ -653,11 +647,10 @@ main = do
653647 then ReferenceObfuscation
654648 else obfuscationMethod }
655649
656− if isNonTextOutput writerName' && outputFile == "-"
657− then do hPutStrLn stderr ("Error: Cannot write " ++ writerName ++ " output to stdout.\n" ++
650+ when (isNonTextOutput writerName' && outputFile == "-") $
651+ do hPutStrLn stderr ("Error: Cannot write " ++ writerName ++ " output to stdout.\n" ++
658652 "Specify an output file using the -o option.")
659− exitWith $ ExitFailure 5
660− else return ()
653+ exitWith $ ExitFailure 5
661654
662655 let sourceDirRelative = if null sources
663656 then ""