git.iko.soy/typeable/pandoc
on master help sign in
Added --list-* options.
273d90bJohn MacFarlane
MANUAL.txt+28−1
@@ -262,7 +262,8 @@ General options
262 `markdown-pipe_tables+hard_line_breaks` is pandoc's Markdown
262 `markdown-pipe_tables+hard_line_breaks` is pandoc's Markdown
263 without pipe tables and with hard line breaks. See [Pandoc's
263 without pipe tables and with hard line breaks. See [Pandoc's
264 Markdown], below, for a list of extensions and
264 Markdown], below, for a list of extensions and
265− their names.
265+ their names. See `--list-input-formats` and `--list-extensions`,
266+ below.
266
267
267`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*
268`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*
268
269
@@ -297,6 +298,7 @@ General options
297 below. Markdown syntax extensions can be individually
298 below. Markdown syntax extensions can be individually
298 enabled or disabled by appending `+EXTENSION` or
299 enabled or disabled by appending `+EXTENSION` or
299 `-EXTENSION` to the format name, as described above under `-f`.
300 `-EXTENSION` to the format name, as described above under `-f`.
301+ See `--list-output-formats` and `--list-extensions`, below.
300
302
301`-o` *FILE*, `--output=`*FILE*
303`-o` *FILE*, `--output=`*FILE*
302
304
@@ -338,6 +340,30 @@ General options
338: Give verbose debugging output. Currently this only has an effect
340: Give verbose debugging output. Currently this only has an effect
339 with PDF output.
341 with PDF output.
340
342
343+`--list-input-formats`
344+
345+: List supported input formats, one per line.
346+
347+`--list-output-formats`
348+
349+: List supported output formats, one per line.
350+
351+`--list-extensions`
352+
353+: List supported Markdown extensions, one per line, followed
354+ by a `+` or `-` indicating whether it is enabled by default
355+ in pandoc's Markdown.
356+
357+`--list-highlight-languages`
358+
359+: List supported languages for syntax highlighting, one per
360+ line.
361+
362+`--list-highlight-styles`
363+
364+: List supported styles for syntax highlighting, one per line.
365+ See `--highlight-style`.
366+
341`-v`, `--version`
367`-v`, `--version`
342
368
343: Print version.
369: Print version.
@@ -583,6 +609,7 @@ General writer options
583 Options are `pygments` (the default), `kate`, `monochrome`,
609 Options are `pygments` (the default), `kate`, `monochrome`,
584 `espresso`, `zenburn`, `haddock`, and `tango`. For more information
610 `espresso`, `zenburn`, `haddock`, and `tango`. For more information
585 on syntax highlighting in pandoc, see [Syntax highlighting], below.
611 on syntax highlighting in pandoc, see [Syntax highlighting], below.
612+ See also `--list-highlight-styles`.
586
613
587`-H` *FILE*, `--include-in-header=`*FILE*
614`-H` *FILE*, `--include-in-header=`*FILE*
588
615
pandoc.hs+63−28
@@ -48,8 +48,9 @@ import System.Environment ( getArgs, getProgName )
48import System.Exit ( ExitCode (..), exitSuccess )
48import System.Exit ( ExitCode (..), exitSuccess )
49import System.FilePath
49import System.FilePath
50import System.Console.GetOpt
50import System.Console.GetOpt
51+import qualified Data.Set as Set
51import Data.Char ( toLower, toUpper )
52import Data.Char ( toLower, toUpper )
52−import Data.List ( delete, intercalate, isPrefixOf, isSuffixOf, sort )
53+import Data.List ( intercalate, isPrefixOf, isSuffixOf, sort )
53import System.Directory ( getAppUserDataDirectory, findExecutable,
54import System.Directory ( getAppUserDataDirectory, findExecutable,
54 doesFileExist, Permissions(..), getPermissions )
55 doesFileExist, Permissions(..), getPermissions )
55import System.IO ( stdout, stderr )
56import System.IO ( stdout, stderr )
@@ -88,10 +89,7 @@ copyrightMessage = intercalate "\n" [
88compileInfo :: String
89compileInfo :: String
89compileInfo =
90compileInfo =
90 "\nCompiled with texmath " ++
91 "\nCompiled with texmath " ++
91− VERSION_texmath ++ ", highlighting-kate " ++ VERSION_highlighting_kate ++
92+ VERSION_texmath ++ ", highlighting-kate " ++ VERSION_highlighting_kate
92− ".\nSyntax highlighting is supported for the following languages:\n " ++
93− wrapWords 4 78
94− [map toLower l | l <- languages, l /= "Alert" && l /= "Alert_indent"]
95
93
96-- | Converts a list of strings into a single string with the items printed as
94-- | Converts a list of strings into a single string with the items printed as
97-- comma separated words in lines with a maximum line length.
95-- comma separated words in lines with a maximum line length.
@@ -158,6 +156,16 @@ externalFilter f args' d = do
158 filterException e = err 83 $ "Error running filter " ++ f ++ "\n" ++
156 filterException e = err 83 $ "Error running filter " ++ f ++ "\n" ++
159 show e
157 show e
160
158
159+highlightingStyles :: [(String, Style)]
160+highlightingStyles =
161+ [("pygments", pygments),
162+ ("tango", tango),
163+ ("espresso", espresso),
164+ ("zenburn", zenburn),
165+ ("kate", kate),
166+ ("monochrome", monochrome),
167+ ("haddock", haddock)]
168+
161-- | Data structure for command line options.
169-- | Data structure for command line options.
162data Opt = Opt
170data Opt = Opt
163 { optTabStop :: Int -- ^ Number of spaces per tab
171 { optTabStop :: Int -- ^ Number of spaces per tab
@@ -517,17 +525,9 @@ options =
517 , Option "" ["highlight-style"]
525 , Option "" ["highlight-style"]
518 (ReqArg
526 (ReqArg
519 (\arg opt -> do
527 (\arg opt -> do
520− newStyle <- case map toLower arg of
528+ case lookup (map toLower arg) highlightingStyles of
521− "pygments" -> return pygments
529+ Just s -> return opt{ optHighlightStyle = s }
522− "tango" -> return tango
523− "espresso" -> return espresso
524− "zenburn" -> return zenburn
525− "kate" -> return kate
526− "monochrome" -> return monochrome
527− "haddock" -> return haddock
528− _ -> err 39 $
529− "Unknown style :" ++ arg
530+ Nothing -> err 39 $ "Unknown style: " ++ arg)
530− return opt{ optHighlightStyle = newStyle })
531 "STYLE")
531 "STYLE")
532 "" -- "Style for highlighted code"
532 "" -- "Style for highlighted code"
533
533
@@ -918,11 +918,56 @@ options =
918 let allopts = unwords (concatMap optnames options)
918 let allopts = unwords (concatMap optnames options)
919 UTF8.hPutStrLn stdout $ printf tpl allopts
919 UTF8.hPutStrLn stdout $ printf tpl allopts
920 (unwords (map fst readers))
920 (unwords (map fst readers))
921− (unwords ("pdf": map fst writers))
921+ (unwords (map fst writers))
922 ddir
922 ddir
923 exitSuccess ))
923 exitSuccess ))
924 "" -- "Print bash completion script"
924 "" -- "Print bash completion script"
925
925
926+ , Option "" ["list-input-formats"]
927+ (NoArg
928+ (\_ -> do
929+ let readers'names = sort (map fst readers)
930+ mapM_ (UTF8.hPutStrLn stdout) readers'names
931+ exitSuccess ))
932+ ""
933+
934+ , Option "" ["list-output-formats"]
935+ (NoArg
936+ (\_ -> do
937+ let writers'names = sort (map fst writers)
938+ mapM_ (UTF8.hPutStrLn stdout) writers'names
939+ exitSuccess ))
940+ ""
941+
942+ , Option "" ["list-extensions"]
943+ (NoArg
944+ (\_ -> do
945+ let showExt x = drop 4 (show x) ++
946+ if x `Set.member` pandocExtensions
947+ then " +"
948+ else " -"
949+ mapM_ (UTF8.hPutStrLn stdout . showExt)
950+ ([minBound..maxBound] :: [Extension])
951+ exitSuccess ))
952+ ""
953+
954+ , Option "" ["list-highlight-languages"]
955+ (NoArg
956+ (\_ -> do
957+ let langs = [map toLower l | l <- languages,
958+ l /= "Alert" && l /= "Alert_indent"]
959+ mapM_ (UTF8.hPutStrLn stdout) langs
960+ exitSuccess ))
961+ ""
962+
963+ , Option "" ["list-highlight-styles"]
964+ (NoArg
965+ (\_ -> do
966+ mapM_ (UTF8.hPutStrLn stdout) $
967+ map fst highlightingStyles
968+ exitSuccess ))
969+ ""
970+
926 , Option "v" ["version"]
971 , Option "v" ["version"]
927 (NoArg
972 (NoArg
928 (\_ -> do
973 (\_ -> do
@@ -961,17 +1006,7 @@ readMetaValue s = case decode (UTF8.fromString s) of
961
1006
962-- Returns usage message
1007-- Returns usage message
963usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
1008usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
964−usageMessage programName = usageInfo
1009+usageMessage programName = usageInfo (programName ++ " [OPTIONS] [FILES]")
965− (programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++
966− wrapWords 16 78 readers'names ++
967− '\n' : replicate 16 ' ' ++
968− "[* only Pandoc's JSON version of native AST]" ++ "\nOutput formats: " ++
969− wrapWords 16 78 writers'names ++
970− '\n' : replicate 16 ' ' ++
971− "[** for pdf output, use latex or beamer and -o FILENAME.pdf]\nOptions:")
972− where
973− writers'names = sort $ "json*" : "pdf**" : delete "json" (map fst writers)
974− readers'names = sort $ "json*" : delete "json" (map fst readers)
975
1010
976-- Determine default reader based on source file extensions
1011-- Determine default reader based on source file extensions
977defaultReaderName :: String -> [FilePath] -> String
1012defaultReaderName :: String -> [FilePath] -> String