git.iko.soy/typeable/pandoc
on master help sign in
Revert "ALlow multiple comma-separated files for `--defaults`."
02c579fJohn MacFarlane
MANUAL.txt+2−3
@@ -356,12 +356,11 @@ header when requesting a document from a URL:
356 `slidy`, `slideous`, or `s5` directory
356 `slidy`, `slideous`, or `s5` directory
357 placed in this directory will override pandoc's normal defaults.
357 placed in this directory will override pandoc's normal defaults.
358
358
359−`-d` *FILE*[,*FILE*,...], `--defaults=`*FILE*[,*FILE*,...]
359+`-d` *FILE*, `--defaults=`*FILE*
360
360
361: Specify a set of default option settings. *FILE* is a YAML
361: Specify a set of default option settings. *FILE* is a YAML
362 file whose fields correspond to command-line option
362 file whose fields correspond to command-line option
363− settings. (Multiple files may be specified, separated by
364− commas.) All options for document conversion, including input
363+ settings. All options for document conversion, including input
365 and output files, can be set using a defaults file. The file will
364 and output files, can be set using a defaults file. The file will
366 be searched for first in the working directory, and then in
365 be searched for first in the working directory, and then in
367 the `defaults` subdirectory of the user data directory
366 the `defaults` subdirectory of the user data directory
src/Text/Pandoc/App/CommandLineOptions.hs+6−7
@@ -64,7 +64,6 @@ import Data.Text (Text)
64import Text.DocTemplates (ToContext(toVal), Context(..))
64import Text.DocTemplates (ToContext(toVal), Context(..))
65import qualified Text.Pandoc.UTF8 as UTF8
65import qualified Text.Pandoc.UTF8 as UTF8
66import qualified Data.YAML as Y
66import qualified Data.YAML as Y
67−import Data.List.Split (splitWhen)
68
67
69parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt
68parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt
70parseOptions options' defaults = do
69parseOptions options' defaults = do
@@ -162,8 +161,11 @@ options =
162
161
163 , Option "d" ["defaults"]
162 , Option "d" ["defaults"]
164 (ReqArg
163 (ReqArg
165− (\arg opt ->
164+ (\arg opt -> do
165+ let fp' = if null (takeExtension arg)
166+ then addExtension arg "yaml"
167+ else arg
166− foldM applyDefaults opt (splitWhen (==',') arg)
168+ foldM applyDefaults opt [fp']
167 )
169 )
168 "FILE")
170 "FILE")
169 ""
171 ""
@@ -980,10 +982,7 @@ splitField s =
980
982
981-- | Apply defaults from --defaults file.
983-- | Apply defaults from --defaults file.
982applyDefaults :: Opt -> FilePath -> IO Opt
984applyDefaults :: Opt -> FilePath -> IO Opt
983−applyDefaults opt filepath = runIOorExplode $ do
985+applyDefaults opt fp = runIOorExplode $ do
984− let fp = if null (takeExtension filepath)
985− then addExtension filepath "yaml"
986− else filepath
987 setVerbosity $ optVerbosity opt
986 setVerbosity $ optVerbosity opt
988 dataDirs <- liftIO defaultUserDataDirs
987 dataDirs <- liftIO defaultUserDataDirs
989 let fps = case optDataDir opt of
988 let fps = case optDataDir opt of