--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.
This commit is contained in:
parent
68b09a6d81
commit
a3cd74c29b
5 changed files with 17 additions and 11 deletions
18
MANUAL.txt
18
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`
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -209,7 +209,7 @@ options =
|
|||
, Option "" ["metadata-file"]
|
||||
(ReqArg
|
||||
(\arg opt -> return opt{ optMetadataFile =
|
||||
(optMetadataFile opt) <> [normalizePath arg] })
|
||||
normalizePath arg : optMetadataFile opt })
|
||||
"FILE")
|
||||
""
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
title: Multiple metadata files test
|
||||
title: This title should be overridden by 5700-metadta-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.
|
||||
|
|
Loading…
Add table
Reference in a new issue