From a3cd74c29be02dde0d65e0dcf79bccc8d41952ed Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 10 Oct 2019 10:00:45 -0700 Subject: `--metadata-file`: when multiple files specified, second takes precedence... on conflicting fields. This changes earlier behavior (but not in a release), where first took precedence. Note that this may seem inconsistent with the behavior of multiple YAML blocks within a document, where the first takes precedence. Still, it is convenient to be able to override defaults with options later on the command line. --- src/Text/Pandoc/App.hs | 4 ++++ src/Text/Pandoc/App/CommandLineOptions.hs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs index ed5963f1a..f3d342ebf 100644 --- a/src/Text/Pandoc/App.hs +++ b/src/Text/Pandoc/App.hs @@ -231,6 +231,10 @@ convertWithOpts opts = do [] -> return mempty paths -> mapM readFileLazy paths >>= mapM (yamlToMeta readerOpts) >>= return . (foldr1 (<>)) + -- Note: this list is in reverse order from the order on the + -- command line. So this code ensures that metadata files + -- specified later in the command line take precedence over + -- those specified earlier. let transforms = (case optShiftHeadingLevelBy opts of 0 -> id diff --git a/src/Text/Pandoc/App/CommandLineOptions.hs b/src/Text/Pandoc/App/CommandLineOptions.hs index f9f825a44..a7b20a6e3 100644 --- a/src/Text/Pandoc/App/CommandLineOptions.hs +++ b/src/Text/Pandoc/App/CommandLineOptions.hs @@ -209,7 +209,7 @@ options = , Option "" ["metadata-file"] (ReqArg (\arg opt -> return opt{ optMetadataFile = - (optMetadataFile opt) <> [normalizePath arg] }) + normalizePath arg : optMetadataFile opt }) "FILE") "" -- cgit v1.2.3