git.iko.soy/typeable/pandoc
on master help sign in
ALlow multiple comma-separated files for `--defaults`.
commite96f3fd813b3f8b73c3457ff6e9177e2a4a74164 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 1 Nov 2019, 10:14 (7 years ago) parent1b69d5e
2 files changed+10−8
MANUAL.txt+3−2 src/Text/Pandoc/App/CommandLineOptions.hs+7−6
MANUAL.txt+3−2
@@ -356,11 +356,12 @@ header when requesting a document from a URL:
356356 `slidy`, `slideous`, or `s5` directory
357357 placed in this directory will override pandoc's normal defaults.
358358
359−`-d` *FILE*, `--defaults=`*FILE*
359+`-d` *FILE*[,*FILE*,...], `--defaults=`*FILE*[,*FILE*,...]
360360
361361: Specify a set of default option settings. *FILE* is a YAML
362362 file whose fields correspond to command-line option
363− settings. All options for document conversion, including input
363+ settings. (Multiple files may be specified, separated by
364+ commas.) All options for document conversion, including input
364365 and output files, can be set using a defaults file. The file will
365366 be searched for first in the working directory, and then in
366367 the `defaults` subdirectory of the user data directory
src/Text/Pandoc/App/CommandLineOptions.hs+7−6
@@ -64,6 +64,7 @@ import Data.Text (Text)
6464import Text.DocTemplates (ToContext(toVal), Context(..))
6565import qualified Text.Pandoc.UTF8 as UTF8
6666import qualified Data.YAML as Y
67+import Data.List.Split (splitWhen)
6768
6869parseOptions :: [OptDescr (Opt -> IO Opt)] -> Opt -> IO Opt
6970parseOptions options' defaults = do
@@ -161,11 +162,8 @@ options =
161162
162163 , Option "d" ["defaults"]
163164 (ReqArg
164− (\arg opt -> do
165− let fp' = if null (takeExtension arg)
166− then addExtension arg "yaml"
167− else arg
168− foldM applyDefaults opt [fp']
165+ (\arg opt ->
166+ foldM applyDefaults opt (splitWhen (==',') arg)
169167 )
170168 "FILE")
171169 ""
@@ -982,7 +980,10 @@ splitField s =
982980
983981-- | Apply defaults from --defaults file.
984982applyDefaults :: 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
986987 setVerbosity $ optVerbosity opt
987988 dataDirs <- liftIO defaultUserDataDirs
988989 let fps = case optDataDir opt of