git.iko.soy/typeable/pandoc
on master help sign in
`--metadata-file`: when multiple files specified, second takes precedence...
a3cd74cJohn MacFarlane
MANUAL.txt+10−8
@@ -606,14 +606,16 @@ header when requesting a document from a URL:
606
606
607`--metadata-file=`*FILE*
607`--metadata-file=`*FILE*
608
608
609−: Read metadata from the supplied YAML (or JSON) file. This option can be used
609+: Read metadata from the supplied YAML (or JSON) file. This
610− with every input format, but string scalars in the YAML file will always be
610+ option can be used with every input format, but string scalars
611+ in the YAML file will always be parsed as Markdown. Generally,
611− parsed as Markdown. Generally, the input will be handled the same as in
612+ the input will be handled the same as in [YAML metadata
612− [YAML metadata blocks][Extension: `yaml_metadata_block`]. This option can be
613+ blocks][Extension: `yaml_metadata_block`]. This option can be
613− used repeatedly to include multiple metadata files; values in files specified
614+ used repeatedly to include multiple metadata files; values in
615+ files specified later on the command line will be preferred
614− first will be preferred over those specified in later files. Metadata values
616+ over those specified in earlier files. Metadata values
615− specified inside the document, or by using `-M`, overwrite values specified
617+ specified inside the document, or by using `-M`, overwrite
616− with this option.
618+ values specified with this option.
617
619
618`-p`, `--preserve-tabs`
620`-p`, `--preserve-tabs`
619
621
src/Text/Pandoc/App.hs+4
@@ -231,6 +231,10 @@ convertWithOpts opts = do
231 [] -> return mempty
231 [] -> return mempty
232 paths -> mapM readFileLazy paths >>= mapM (yamlToMeta readerOpts)
232 paths -> mapM readFileLazy paths >>= mapM (yamlToMeta readerOpts)
233 >>= return . (foldr1 (<>))
233 >>= 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.
234
238
235 let transforms = (case optShiftHeadingLevelBy opts of
239 let transforms = (case optShiftHeadingLevelBy opts of
236 0 -> id
240 0 -> id
src/Text/Pandoc/App/CommandLineOptions.hs+1−1
@@ -209,7 +209,7 @@ options =
209 , Option "" ["metadata-file"]
209 , Option "" ["metadata-file"]
210 (ReqArg
210 (ReqArg
211 (\arg opt -> return opt{ optMetadataFile =
211 (\arg opt -> return opt{ optMetadataFile =
212− (optMetadataFile opt) <> [normalizePath arg] })
212+ normalizePath arg : optMetadataFile opt })
213 "FILE")
213 "FILE")
214 ""
214 ""
215
215
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
2desc: Both of these files should be loaded.
2desc: Both of these files should be loaded.