git.iko.soy/typeable/pandoc
on master help sign in
`--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.

commita3cd74c29be02dde0d65e0dcf79bccc8d41952ed authorJohn MacFarlane <jgm@berkeley.edu> dateThu 10 Oct 2019, 10:00 (7 years ago) parent68b09a6
5 files changed+17−11
MANUAL.txt+10−8 src/Text/Pandoc/App.hs+4 src/Text/Pandoc/App/CommandLineOptions.hs+1−1 test/command/5700-metadata-file-1.yml+1−1 test/command/5700-metadata-file-2.yml+1−1
MANUAL.txt+10−8
@@ -606,14 +606,16 @@ header when requesting a document from a URL:
606606
607607`--metadata-file=`*FILE*
608608
609−: Read metadata from the supplied YAML (or JSON) file. This option can be used
610− with every input format, but string scalars in the YAML file will always be
611− parsed as Markdown. Generally, the input will be handled the same as in
612− [YAML metadata blocks][Extension: `yaml_metadata_block`]. This option can be
613− used repeatedly to include multiple metadata files; values in files specified
614− first will be preferred over those specified in later files. Metadata values
615− specified inside the document, or by using `-M`, overwrite values specified
616− with this option.
609+: Read metadata from the supplied YAML (or JSON) file. This
610+ option can be used with every input format, but string scalars
611+ in the YAML file will always be parsed as Markdown. Generally,
612+ the input will be handled the same as in [YAML metadata
613+ blocks][Extension: `yaml_metadata_block`]. This option can be
614+ used repeatedly to include multiple metadata files; values in
615+ files specified later on the command line will be preferred
616+ over those specified in earlier files. Metadata values
617+ specified inside the document, or by using `-M`, overwrite
618+ values specified with this option.
617619
618620`-p`, `--preserve-tabs`
619621
src/Text/Pandoc/App.hs+4
@@ -231,6 +231,10 @@ convertWithOpts opts = do
231231 [] -> return mempty
232232 paths -> mapM readFileLazy paths >>= mapM (yamlToMeta readerOpts)
233233 >>= return . (foldr1 (<>))
234+ -- Note: this list is in reverse order from the order on the
235+ -- command line. So this code ensures that metadata files
236+ -- specified later in the command line take precedence over
237+ -- those specified earlier.
234238
235239 let transforms = (case optShiftHeadingLevelBy opts of
236240 0 -> id
src/Text/Pandoc/App/CommandLineOptions.hs+1−1
@@ -209,7 +209,7 @@ options =
209209 , Option "" ["metadata-file"]
210210 (ReqArg
211211 (\arg opt -> return opt{ optMetadataFile =
212− (optMetadataFile opt) <> [normalizePath arg] })
212+ normalizePath arg : optMetadataFile opt })
213213 "FILE")
214214 ""
215215
test/command/5700-metadata-file-1.yml+1−1
@@ -1 +1 @@
1−title: Multiple metadata files test
1+title: This title should be overridden by 5700-metadta-file-2.yml
test/command/5700-metadata-file-2.yml+1−1
@@ -1,2 +1,2 @@
1−title: This title should be overridden by 5700-metadta-file-2.yml
1+title: Multiple metadata files test
22desc: Both of these files should be loaded.