diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2009-05-01 04:18:14 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2009-05-01 04:18:14 +0000 |
commit | cceede4ca20f1f362b7bc6868618177f9c7b4bab (patch) | |
tree | 6c57f97ece3ad82b8993818a3afeb668f21c1169 /src/markdown2pdf.hs | |
parent | 2d5f71804808bb7f3e7d3f5168156d29e78d5a5b (diff) |
Added new Haskell version of markdown2pdf.
Thanks to Paulo Tanimoto for the patch.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1573 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/markdown2pdf.hs')
-rw-r--r-- | src/markdown2pdf.hs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/markdown2pdf.hs b/src/markdown2pdf.hs index 7a557069b..dcadfb334 100644 --- a/src/markdown2pdf.hs +++ b/src/markdown2pdf.hs @@ -1,6 +1,6 @@ module Main where -import Data.List (isInfixOf, intercalate, intersect) +import Data.List (isInfixOf, intercalate, (\\)) import Data.Maybe (isNothing) import Control.Monad (when, unless, guard) @@ -153,23 +153,24 @@ main = bracket paths <- mapM findExecutable execs let miss = map snd $ filter (isNothing . fst) $ zip paths execs unless (null miss) $ exit $! "Could not find " ++ intercalate ", " miss - -- parse arguments args <- getArgs - let badopts = ["-t","-w","--to","--write","-s","--standalone", - "--reference-links","-m","--latexmathml", - "--asciimathml","--mimetex","--jsmath","--gladtex", - "-i","--incremental","--no-wrap", "--sanitize-html", - "--email-obfuscation","-c","--css","-T","--title-prefix", - "-D","--print-default-header","--dump-args", - "--ignore-args","-h","--help","-v","--version"] - let badoptsLong = filter (\o -> length o > 2) badopts - unless (null (args `intersect` badopts)) $ do + -- check for invalid arguments and print help message if needed + let goodopts = ["-f","-r","--from","--read","--strict","-N", + "-p","--preserve-tabs","--tab-stop","-R","--parse-raw", + "--toc","--table-of-contents", + "--number-sections","-H","--include-in-header", + "-B","--include-before-body","-A","--include-after-body", + "-C","--custom-header","-o","--output"] + let goodoptsLong = filter (\op -> length op > 2) goodopts + let isOpt ('-':_) = True + isOpt _ = False + unless (null (filter isOpt args \\ goodopts)) $ do (code, out, _err) <- readProcessWithExitCode "pandoc" ["--help"] "" - putStrLn "markdown2pdf [OPTIONS] [FILES]" - putStrLn $ unlines $ drop 3 $ - filter (\l -> not . any (`isInfixOf` l) $ badoptsLong) $ - lines out + putStrLn "markdown2pdf [OPTIONS] [FILES]\nOptions:" + putStr $ unlines $ + filter (\l -> any (`isInfixOf` l) goodoptsLong) $ lines out exitWith code + -- parse arguments pandocArgs <- parsePandocArgs args (inputs, output) <- case pandocArgs of Nothing -> exit "Could not parse arguments" |