git.iko.soy/typeable/pandoc
on master help sign in
Main: use Text.Pandoc to simplify list of imported modules.
ba6efb0fiddlosopher
src/Main.hs+9−24
@@ -29,26 +29,10 @@ Parses command-line options and calls the appropriate readers and
29writers.
29writers.
30-}
30-}
31module Main where
31module Main where
32−import Text.Pandoc.UTF8 ( decodeUTF8, encodeUTF8 )
32+import Text.Pandoc
33−import Text.Pandoc.Readers.Markdown ( readMarkdown )
33+import Text.Pandoc.UTF8 ( encodeUTF8, decodeUTF8 )
34−import Text.Pandoc.Readers.HTML ( readHtml )
35−import Text.Pandoc.Writers.S5 ( writeS5String )
36−import Text.Pandoc.Writers.RST ( writeRST )
37−import Text.Pandoc.Readers.RST ( readRST )
38import Text.Pandoc.ASCIIMathML ( asciiMathMLScript )
34import Text.Pandoc.ASCIIMathML ( asciiMathMLScript )
39−import Text.Pandoc.Writers.HTML ( writeHtmlString )
35+import Text.Pandoc.Shared ( joinWithSep, tabsToSpaces )
40−import Text.Pandoc.Writers.Docbook ( writeDocbook )
41−import Text.Pandoc.Writers.LaTeX ( writeLaTeX )
42−import Text.Pandoc.Readers.LaTeX ( readLaTeX )
43−import Text.Pandoc.Writers.RTF ( writeRTF )
44−import Text.Pandoc.Writers.Man ( writeMan )
45−import Text.Pandoc.Writers.Markdown ( writeMarkdown )
46−import Text.Pandoc.Writers.DefaultHeaders ( defaultRTFHeader,
47− defaultS5Header,
48− defaultLaTeXHeader,
49− defaultDocbookHeader )
50−import Text.Pandoc.Definition
51−import Text.Pandoc.Shared
52import Text.Regex ( mkRegex, matchRegex )
36import Text.Regex ( mkRegex, matchRegex )
53import System.Environment ( getArgs, getProgName, getEnvironment )
37import System.Environment ( getArgs, getProgName, getEnvironment )
54import System.Exit ( exitWith, ExitCode (..) )
38import System.Exit ( exitWith, ExitCode (..) )
@@ -159,13 +143,13 @@ options =
159 (ReqArg
143 (ReqArg
160 (\arg opt -> return opt { optReader = map toLower arg })
144 (\arg opt -> return opt { optReader = map toLower arg })
161 "FORMAT")
145 "FORMAT")
162− "" -- ("(" ++ (joinWithSep ", " (map fst readers)) ++ ")")
146+ "" -- ("(" ++ (joinWithSep ", " $ map fst readers) ++ ")")
163
147
164 , Option "tw" ["to","write"]
148 , Option "tw" ["to","write"]
165 (ReqArg
149 (ReqArg
166 (\arg opt -> return opt { optWriter = map toLower arg })
150 (\arg opt -> return opt { optWriter = map toLower arg })
167 "FORMAT")
151 "FORMAT")
168− "" -- ("(" ++ (joinWithSep ", " (map fst writers)) ++ ")")
152+ "" -- ("(" ++ (joinWithSep ", " $ map fst writers) ++ ")")
169
153
170 , Option "s" ["standalone"]
154 , Option "s" ["standalone"]
171 (NoArg
155 (NoArg
@@ -321,8 +305,8 @@ options =
321usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
305usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
322usageMessage programName options = usageInfo
306usageMessage programName options = usageInfo
323 (programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++
307 (programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++
324− joinWithSep ", " (map fst readers) ++ "\nOutput formats: " ++
308+ (joinWithSep ", " $ map fst readers) ++ "\nOutput formats: " ++
325− joinWithSep ", " (map fst writers) ++ "\nOptions:")
309+ (joinWithSep ", " $ map fst writers) ++ "\nOptions:")
326 options
310 options
327
311
328-- Determine default reader based on source file extensions
312-- Determine default reader based on source file extensions
@@ -494,7 +478,8 @@ main = do
494 (readSources sources) >>= (hPutStr output . encodeUTF8 .
478 (readSources sources) >>= (hPutStr output . encodeUTF8 .
495 (writer writerOptions) .
479 (writer writerOptions) .
496 (reader startParserState) . filter .
480 (reader startParserState) . filter .
497− decodeUTF8 . (joinWithSep "\n")) >> hClose output
481+ decodeUTF8 . (joinWithSep "\n")) >>
482+ hClose output
498
483
499 where
484 where
500 readSources [] = mapM readSource ["-"]
485 readSources [] = mapM readSource ["-"]