@@ -144,75 +144,73 @@ options =
145 (\arg opt -> return opt { optReader = map toLower arg })
145 (\arg opt -> return opt { optReader = map toLower arg })
146 "FORMAT")
146 "FORMAT")
147− ("Input format (" ++ (joinWithSep ", " (map fst readers)) ++
147+ "" -- ("(" ++ (joinWithSep ", " (map fst readers)) ++ ")")
150 , Option "tw" ["to","write"]
149 , Option "tw" ["to","write"]
152 (\arg opt -> return opt { optWriter = map toLower arg })
151 (\arg opt -> return opt { optWriter = map toLower arg })
153 "FORMAT")
152 "FORMAT")
154− ("Output format (" ++ (joinWithSep ", " (map fst writers)) ++
153+ "" -- ("(" ++ (joinWithSep ", " (map fst writers)) ++ ")")
157 , Option "s" ["standalone"]
155 , Option "s" ["standalone"]
159 (\opt -> return opt { optStandalone = True }))
157 (\opt -> return opt { optStandalone = True }))
160− "Include needed header and footer on output"
158+ "" -- "Include needed header and footer on output"
162 , Option "o" ["output"]
160 , Option "o" ["output"]
164 (\arg opt -> return opt { optOutputFile = arg })
162 (\arg opt -> return opt { optOutputFile = arg })
165 "FILENAME")
163 "FILENAME")
166− "Name of output file"
164+ "" -- "Name of output file"
168 , Option "p" ["preserve-tabs"]
166 , Option "p" ["preserve-tabs"]
170 (\opt -> return opt { optPreserveTabs = True }))
168 (\opt -> return opt { optPreserveTabs = True }))
171− "Preserve tabs instead of converting to spaces"
169+ "" -- "Preserve tabs instead of converting to spaces"
173 , Option "" ["tab-stop"]
171 , Option "" ["tab-stop"]
175 (\arg opt -> return opt { optTabStop = (read arg) } )
173 (\arg opt -> return opt { optTabStop = (read arg) } )
176 "TABSTOP")
174 "TABSTOP")
177− "Tab stop (default 4)"
175+ "" -- "Tab stop (default 4)"
179 , Option "" ["strict"]
177 , Option "" ["strict"]
181 (\opt -> return opt { optStrict = True } ))
179 (\opt -> return opt { optStrict = True } ))
182− "Use strict markdown syntax with no extensions"
180+ "" -- "Use strict markdown syntax with no extensions"
184 , Option "R" ["parse-raw"]
182 , Option "R" ["parse-raw"]
186 (\opt -> return opt { optParseRaw = True }))
184 (\opt -> return opt { optParseRaw = True }))
187− "Parse untranslatable HTML codes and LaTeX environments as raw"
185+ "" -- "Parse untranslatable HTML codes and LaTeX environments as raw"
189 , Option "S" ["smart"]
187 , Option "S" ["smart"]
191 (\opt -> return opt { optSmart = True }))
189 (\opt -> return opt { optSmart = True }))
192− "Use smart quotes, dashes, and ellipses in HTML output"
190+ "" -- "Use smart quotes, dashes, and ellipses in HTML output"
194 , Option "m" ["asciimathml"]
192 , Option "m" ["asciimathml"]
196 (\opt -> return opt { optASCIIMathML = True,
194 (\opt -> return opt { optASCIIMathML = True,
197 optStandalone = True }))
195 optStandalone = True }))
198− "Use ASCIIMathML script in html output"
196+ "" -- "Use ASCIIMathML script in html output"
200 , Option "i" ["incremental"]
198 , Option "i" ["incremental"]
202 (\opt -> return opt { optIncremental = True }))
200 (\opt -> return opt { optIncremental = True }))
203− "Make list items display incrementally in S5"
201+ "" -- "Make list items display incrementally in S5"
205 , Option "N" ["number-sections"]
203 , Option "N" ["number-sections"]
207 (\opt -> return opt { optNumberSections = True }))
205 (\opt -> return opt { optNumberSections = True }))
208− "Number sections in LaTeX"
206+ "" -- "Number sections in LaTeX"
210 , Option "c" ["css"]
208 , Option "c" ["css"]
212 (\arg opt -> return opt { optCSS = arg,
210 (\arg opt -> return opt { optCSS = arg,
213 optStandalone = True })
211 optStandalone = True })
215− "Link to CSS style sheet"
213+ "" -- "Link to CSS style sheet"
217 , Option "H" ["include-in-header"]
215 , Option "H" ["include-in-header"]
@@ -221,7 +219,7 @@ options =
221 return opt { optIncludeInHeader = text,
219 return opt { optIncludeInHeader = text,
222 optStandalone = True })
220 optStandalone = True })
223 "FILENAME")
221 "FILENAME")
224− "File to include at end of header (implies -s)"
222+ "" -- "File to include at end of header (implies -s)"
226 , Option "B" ["include-before-body"]
224 , Option "B" ["include-before-body"]
@@ -229,7 +227,7 @@ options =
229 text <- readFile arg
227 text <- readFile arg
230 return opt { optIncludeBeforeBody = text })
228 return opt { optIncludeBeforeBody = text })
231 "FILENAME")
229 "FILENAME")
232− "File to include before document body"
230+ "" -- "File to include before document body"
234 , Option "A" ["include-after-body"]
232 , Option "A" ["include-after-body"]
@@ -237,7 +235,7 @@ options =
237 text <- readFile arg
235 text <- readFile arg
238 return opt { optIncludeAfterBody = text })
236 return opt { optIncludeAfterBody = text })
239 "FILENAME")
237 "FILENAME")
240− "File to include after document body"
238+ "" -- "File to include after document body"
242 , Option "C" ["custom-header"]
240 , Option "C" ["custom-header"]
@@ -246,14 +244,14 @@ options =
246 return opt { optCustomHeader = text,
244 return opt { optCustomHeader = text,
247 optStandalone = True })
245 optStandalone = True })
248 "FILENAME")
246 "FILENAME")
249− "File to use for custom header (implies -s)"
247+ "" -- "File to use for custom header (implies -s)"
251 , Option "T" ["title-prefix"]
249 , Option "T" ["title-prefix"]
253 (\arg opt -> return opt { optTitlePrefix = arg,
251 (\arg opt -> return opt { optTitlePrefix = arg,
254 optStandalone = True })
252 optStandalone = True })
255 "STRING")
253 "STRING")
256− "String to prefix to HTML window title"
254+ "" -- "String to prefix to HTML window title"
258 , Option "D" ["print-default-header"]
256 , Option "D" ["print-default-header"]
@@ -264,12 +262,12 @@ options =
264 hPutStr stdout header
262 hPutStr stdout header
265 exitWith ExitSuccess)
263 exitWith ExitSuccess)
266 "FORMAT")
264 "FORMAT")
267− "Print default header for FORMAT"
265+ "" -- "Print default header for FORMAT"
269 , Option "d" ["debug"]
267 , Option "d" ["debug"]
271 (\opt -> return opt { optDebug = True }))
269 (\opt -> return opt { optDebug = True }))
272− "Print debug messages to stderr, output to stdout"
270+ "" -- "Print debug messages to stderr, output to stdout"
274 , Option "v" ["version"]
272 , Option "v" ["version"]
@@ -278,24 +276,25 @@ options =
278 hPutStrLn stderr (prg ++ " " ++ version ++
276 hPutStrLn stderr (prg ++ " " ++ version ++
279 copyrightMessage)
277 copyrightMessage)
280 exitWith $ ExitFailure 2))
278 exitWith $ ExitFailure 2))
281− "Print version"
279+ "" -- "Print version"
283 , Option "h" ["help"]
281 , Option "h" ["help"]
285 (\_ -> do
283 (\_ -> do
286 prg <- getProgName
284 prg <- getProgName
287− hPutStr stderr (reformatUsageInfo $
285+ hPutStr stderr (usageMessage prg options)
288− usageInfo (prg ++ " [OPTIONS] [FILES]") options)
289 exitWith $ ExitFailure 2))
286 exitWith $ ExitFailure 2))
290− "Show help"
287+ "" -- "Show help"
293−-- Reformat usage message so it doesn't wrap illegibly
290+-- Returns usage message
294−reformatUsageInfo :: String -> String
291+usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
295−reformatUsageInfo = gsub " *--" " --" .
292+usageMessage programName options = usageInfo
296− gsub "(-[A-Za-z0-9]) *--" "\\1, --" .
293+ (programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++
297− gsub " *([^- ])" "\n\t\\1"
294+ joinWithSep ", " (map fst readers) ++ "\nOutput formats: " ++
298−
295+ joinWithSep ", " (map fst writers) ++ "\nOptions:")
299-- Determine default reader based on source file extensions
298-- Determine default reader based on source file extensions
300defaultReaderName :: [String] -> String
299defaultReaderName :: [String] -> String
301defaultReaderName [] = "markdown"
300defaultReaderName [] = "markdown"
@@ -343,8 +342,7 @@ main = do
344 name <- getProgName
343 name <- getProgName
345 mapM (\e -> hPutStrLn stderr e) errors
344 mapM (\e -> hPutStrLn stderr e) errors
346− hPutStrLn stderr (reformatUsageInfo $
345+ hPutStr stderr (usageMessage name options)
347− usageInfo (name ++ " [OPTIONS] [FILES]") options)
348 exitWith $ ExitFailure 2
346 exitWith $ ExitFailure 2
350 return ()
348 return ()