@@ -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 " ++
94− [map toLower l | l <- languages, l /= "Alert" && l /= "Alert_indent"]
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+highlightingStyles :: [(String, Style)]
161+ [("pygments", pygments),
163+ ("espresso", espresso),
164+ ("zenburn", zenburn),
166+ ("monochrome", monochrome),
167+ ("haddock", haddock)]
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"]
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
529− "Unknown style :" ++ arg
530+ Nothing -> err 39 $ "Unknown style: " ++ arg)
530− return opt{ optHighlightStyle = newStyle })
532 "" -- "Style for highlighted code"
532 "" -- "Style for highlighted code"
@@ -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))
923 exitSuccess ))
923 exitSuccess ))
924 "" -- "Print bash completion script"
924 "" -- "Print bash completion script"
926+ , Option "" ["list-input-formats"]
929+ let readers'names = sort (map fst readers)
930+ mapM_ (UTF8.hPutStrLn stdout) readers'names
934+ , Option "" ["list-output-formats"]
937+ let writers'names = sort (map fst writers)
938+ mapM_ (UTF8.hPutStrLn stdout) writers'names
942+ , Option "" ["list-extensions"]
945+ let showExt x = drop 4 (show x) ++
946+ if x `Set.member` pandocExtensions
949+ mapM_ (UTF8.hPutStrLn stdout . showExt)
950+ ([minBound..maxBound] :: [Extension])
954+ , Option "" ["list-highlight-languages"]
957+ let langs = [map toLower l | l <- languages,
958+ l /= "Alert" && l /= "Alert_indent"]
959+ mapM_ (UTF8.hPutStrLn stdout) langs
963+ , Option "" ["list-highlight-styles"]
966+ mapM_ (UTF8.hPutStrLn stdout) $
967+ map fst highlightingStyles
926 , Option "v" ["version"]
971 , Option "v" ["version"]
928 (\_ -> do
973 (\_ -> do
@@ -961,17 +1006,7 @@ readMetaValue s = case decode (UTF8.fromString s) of
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:")
973− writers'names = sort $ "json*" : "pdf**" : delete "json" (map fst writers)
974− readers'names = sort $ "json*" : delete "json" (map fst readers)
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