aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANUAL.txt18
-rw-r--r--src/Text/Pandoc/App.hs4
-rw-r--r--src/Text/Pandoc/App/CommandLineOptions.hs2
-rw-r--r--test/command/5700-metadata-file-1.yml2
-rw-r--r--test/command/5700-metadata-file-2.yml2
5 files changed, 17 insertions, 11 deletions
diff --git a/MANUAL.txt b/MANUAL.txt
index f7373b4c4..25f76b9aa 100644
--- a/MANUAL.txt
+++ b/MANUAL.txt
@@ -606,14 +606,16 @@ header when requesting a document from a URL:
`--metadata-file=`*FILE*
-: Read metadata from the supplied YAML (or JSON) file. This option can be used
- with every input format, but string scalars in the YAML file will always be
- parsed as Markdown. Generally, the input will be handled the same as in
- [YAML metadata blocks][Extension: `yaml_metadata_block`]. This option can be
- used repeatedly to include multiple metadata files; values in files specified
- first will be preferred over those specified in later files. Metadata values
- specified inside the document, or by using `-M`, overwrite values specified
- with this option.
+: Read metadata from the supplied YAML (or JSON) file. This
+ option can be used with every input format, but string scalars
+ in the YAML file will always be parsed as Markdown. Generally,
+ the input will be handled the same as in [YAML metadata
+ blocks][Extension: `yaml_metadata_block`]. This option can be
+ used repeatedly to include multiple metadata files; values in
+ files specified later on the command line will be preferred
+ over those specified in earlier files. Metadata values
+ specified inside the document, or by using `-M`, overwrite
+ values specified with this option.
`-p`, `--preserve-tabs`
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")
""
diff --git a/test/command/5700-metadata-file-1.yml b/test/command/5700-metadata-file-1.yml
index df64e99c5..8289c392b 100644
--- a/test/command/5700-metadata-file-1.yml
+++ b/test/command/5700-metadata-file-1.yml
@@ -1 +1 @@
-title: Multiple metadata files test
+title: This title should be overridden by 5700-metadta-file-2.yml
diff --git a/test/command/5700-metadata-file-2.yml b/test/command/5700-metadata-file-2.yml
index e865ed55d..1d5510e07 100644
--- a/test/command/5700-metadata-file-2.yml
+++ b/test/command/5700-metadata-file-2.yml
@@ -1,2 +1,2 @@
-title: This title should be overridden by 5700-metadta-file-2.yml
+title: Multiple metadata files test
desc: Both of these files should be loaded.