git.iko.soy/typeable/pandoc
on master help sign in
ALlow multiple comma-separated files for `--defaults`.
e96f3fdJohn MacFarlane
MANUAL.txt+3−2
@@ -356,11 +356,12 @@ 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*, `--defaults=`*FILE*
359+`-d` *FILE*[,*FILE*,...], `--defaults=`*FILE*[,*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
363− settings. All options for document conversion, including input
364+ commas.) All options for document conversion, including input
364 and output files, can be set using a defaults file. The file will
365 and output files, can be set using a defaults file. The file will
365 be searched for first in the working directory, and then in
366 be searched for first in the working directory, and then in
366 the `defaults` subdirectory of the user data directory
367 the `defaults` subdirectory of the user data directory
src/Text/Pandoc/App/CommandLineOptions.hs+7−6
@@ -64,6 +64,7 @@ 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)
67
68
68parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt
69parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt
69parseOptions options' defaults = do
70parseOptions options' defaults = do
@@ -161,11 +162,8 @@ options =
161
162
162 , Option "d" ["defaults"]
163 , Option "d" ["defaults"]
163 (ReqArg
164 (ReqArg
164− (\arg opt -> do
165+ (\arg opt ->
165− let fp' = if null (takeExtension arg)
166− then addExtension arg "yaml"
167− else arg
168− foldM applyDefaults opt [fp']
166+ foldM applyDefaults opt (splitWhen (==',') arg)
169 )
167 )
170 "FILE")
168 "FILE")
171 ""
169 ""
@@ -982,7 +980,10 @@ splitField s =
982
980
983-- | Apply defaults from --defaults file.
981-- | Apply defaults from --defaults file.
984applyDefaults :: Opt -> FilePath -> IO Opt
982applyDefaults :: Opt -> FilePath -> IO Opt
985−applyDefaults opt fp = runIOorExplode $ do
983+applyDefaults opt filepath = runIOorExplode $ do
984+ let fp = if null (takeExtension filepath)
985+ then addExtension filepath "yaml"
986+ else filepath
986 setVerbosity $ optVerbosity opt
987 setVerbosity $ optVerbosity opt
987 dataDirs <- liftIO defaultUserDataDirs
988 dataDirs <- liftIO defaultUserDataDirs
988 let fps = case optDataDir opt of
989 let fps = case optDataDir opt of