diff options
Diffstat (limited to 'src/Text/Pandoc/App')
-rw-r--r-- | src/Text/Pandoc/App/CommandLineOptions.hs | 6 | ||||
-rw-r--r-- | src/Text/Pandoc/App/Opt.hs | 13 | ||||
-rw-r--r-- | src/Text/Pandoc/App/OutputSettings.hs | 5 |
3 files changed, 15 insertions, 9 deletions
diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs index 56b1f780a..1776107ff 100644 --- a/src/Text/Pandoc/App/CommandLineOptions.hs +++ b/src/Text/Pandoc/App/CommandLineOptions.hs @@ -85,7 +85,11 @@ parseOptions options' defaults = do -- thread option data structure through all supplied option actions opts <- foldl (>>=) (return defaults) actions - return (opts{ optInputFiles = map normalizePath $ optInputFiles opts ++ args }) + let mbArgs = case args of + [] -> Nothing + xs -> Just xs + return $ opts{ optInputFiles = + map normalizePath <$> (optInputFiles opts <> mbArgs) } latexEngines :: [String] latexEngines = ["pdflatex", "lualatex", "xelatex", "latexmk", "tectonic"] diff --git a/src/Text/Pandoc/App/Opt.hs b/src/Text/Pandoc/App/Opt.hs index 402d09bb7..ed167fff2 100644 --- a/src/Text/Pandoc/App/Opt.hs +++ b/src/Text/Pandoc/App/Opt.hs @@ -85,7 +85,7 @@ data Opt = Opt , optMetadata :: Meta -- ^ Metadata fields to set , optMetadataFiles :: [FilePath] -- ^ Name of YAML metadata files , optOutputFile :: Maybe FilePath -- ^ Name of output file - , optInputFiles :: [FilePath] -- ^ Names of input files + , optInputFiles :: Maybe [FilePath] -- ^ Names of input files , optNumberSections :: Bool -- ^ Number sections in LaTeX , optNumberOffset :: [Int] -- ^ Starting number for sections , optSectionDivs :: Bool -- ^ Put sections in div tags in HTML @@ -200,16 +200,17 @@ doOpt (k',v) = do "output-file" -> parseYAML v >>= \x -> return (\o -> o{ optOutputFile = unpack <$> x }) "input-files" -> - parseYAML v >>= \x -> return (\o -> o{ optInputFiles = optInputFiles o <> - map unpack x }) + parseYAML v >>= \x -> return (\o -> o{ optInputFiles = + optInputFiles o <> + Just (map unpack x) }) "input-file" -> -- allow either a list or a single value (parseYAML v >>= \x -> return (\o -> o{ optInputFiles = optInputFiles o <> - map unpack x })) + Just (map unpack x) })) <|> (parseYAML v >>= \x -> return (\o -> o{ optInputFiles = optInputFiles o <> - [unpack x] })) + Just [unpack x] })) "number-sections" -> parseYAML v >>= \x -> return (\o -> o{ optNumberSections = x }) "number-offset" -> @@ -390,7 +391,7 @@ defaultOpts = Opt , optMetadata = mempty , optMetadataFiles = [] , optOutputFile = Nothing - , optInputFiles = [] + , optInputFiles = Nothing , optNumberSections = False , optNumberOffset = [0,0,0,0,0,0] , optSectionDivs = False diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs index 4f33bd336..944f1b63b 100644 --- a/src/Text/Pandoc/App/OutputSettings.hs +++ b/src/Text/Pandoc/App/OutputSettings.hs @@ -63,7 +63,7 @@ optToOutputSettings opts = do when (optDumpArgs opts) . liftIO $ do UTF8.hPutStrLn stdout outputFile - mapM_ (UTF8.hPutStrLn stdout) (optInputFiles opts) + mapM_ (UTF8.hPutStrLn stdout) (fromMaybe [] $ optInputFiles opts) exitSuccess epubMetadata <- case optEpubMetadata opts of @@ -140,7 +140,8 @@ optToOutputSettings opts = do variables <- return (optVariables opts) >>= - setListVariableM "sourcefile" (T.pack <$> optInputFiles opts) + setListVariableM "sourcefile" + (maybe ["-"] (fmap T.pack) (optInputFiles opts)) >>= setVariableM "outputfile" outputFile >>= |