Default files: combine with prior values when appropriate.
Certain command-line arguments can be repeated: `--metadata-file`, `--css`, `--include-in-header`, `--include-before-body`, `--include-after-body`, `--variable`, `--metadata`, `--syntax-definition`. In these cases, values specified in default files should be added to the list rather than replacing values specified earlier on the command line (perhaps in other default files). So, for example, if one does pandoc --variable foo=3 --defaults d1 --defaults d2 and `d1` sets the variable `bar` and `d2` sets `baz`, all three variables will be set. Closes #5894.
This commit is contained in:
parent
28a1f50111
commit
ec043e0d97
2 changed files with 54 additions and 21 deletions
|
@ -1591,6 +1591,15 @@ of the user data directory, and then invoke these defaults
|
|||
from any directory using `pandoc --defaults letter`
|
||||
or `pandoc -dletter`.
|
||||
|
||||
When multiple defaults are used, their contents will be combined.
|
||||
|
||||
Note that, where command-line arguments may be repeated
|
||||
(`--metadata-file`, `--css`, `--include-in-header`,
|
||||
`--include-before-body`, `--include-after-body`, `--variable`,
|
||||
`--metadata`, `--syntax-definition`), the values specified on
|
||||
the command line will combine with values specified in the
|
||||
defaults file, rather than replacing them.
|
||||
|
||||
# Templates
|
||||
|
||||
When the `-s/--standalone` option is used, pandoc uses a template to
|
||||
|
|
|
@ -179,25 +179,37 @@ doOpt (k',v) = do
|
|||
"template" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optTemplate = unpack <$> x })
|
||||
"variables" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optVariables = x })
|
||||
parseYAML v >>= \x -> return (\o -> o{ optVariables =
|
||||
optVariables o <> x })
|
||||
"metadata" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optMetadata = contextToMeta x })
|
||||
parseYAML v >>= \x -> return (\o -> o{ optMetadata = optMetadata o <>
|
||||
contextToMeta x })
|
||||
"metadata-files" ->
|
||||
(parseYAML v >>= \x ->
|
||||
return (\o -> o{ optMetadataFiles = map unpack x }))
|
||||
return (\o -> o{ optMetadataFiles =
|
||||
optMetadataFiles o <>
|
||||
map unpack x }))
|
||||
"metadata-file" -> -- allow either a list or a single value
|
||||
(parseYAML v >>= \x -> return (\o -> o{ optMetadataFiles = map unpack x }))
|
||||
(parseYAML v >>= \x -> return (\o -> o{ optMetadataFiles =
|
||||
optMetadataFiles o <>
|
||||
map unpack x }))
|
||||
<|>
|
||||
(parseYAML v >>= \x ->
|
||||
return (\o -> o{ optMetadataFiles = [unpack x] }))
|
||||
return (\o -> o{ optMetadataFiles =
|
||||
optMetadataFiles o <>[unpack x] }))
|
||||
"output-file" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optOutputFile = unpack <$> x })
|
||||
"input-files" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optInputFiles = map unpack x })
|
||||
parseYAML v >>= \x -> return (\o -> o{ optInputFiles = optInputFiles o <>
|
||||
map unpack x })
|
||||
"input-file" -> -- allow either a list or a single value
|
||||
(parseYAML v >>= \x -> return (\o -> o{ optInputFiles = map unpack x }))
|
||||
(parseYAML v >>= \x -> return (\o -> o{ optInputFiles =
|
||||
optInputFiles o <>
|
||||
map unpack x }))
|
||||
<|>
|
||||
(parseYAML v >>= \x -> return (\o -> o{ optInputFiles = [unpack x] }))
|
||||
(parseYAML v >>= \x -> return (\o -> o{ optInputFiles =
|
||||
optInputFiles o <>
|
||||
[unpack x] }))
|
||||
"number-sections" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optNumberSections = x })
|
||||
"number-offset" ->
|
||||
|
@ -214,13 +226,16 @@ doOpt (k',v) = do
|
|||
parseYAML v >>= \x -> return (\o -> o{ optHighlightStyle = x })
|
||||
"syntax-definition" ->
|
||||
(parseYAML v >>= \x ->
|
||||
return (\o -> o{ optSyntaxDefinitions = map unpack x }))
|
||||
return (\o -> o{ optSyntaxDefinitions =
|
||||
optSyntaxDefinitions o <> map unpack x }))
|
||||
<|>
|
||||
(parseYAML v >>= \x ->
|
||||
return (\o -> o{ optSyntaxDefinitions = [unpack x] }))
|
||||
return (\o -> o{ optSyntaxDefinitions =
|
||||
optSyntaxDefinitions o <> [unpack x] }))
|
||||
"syntax-definitions" ->
|
||||
parseYAML v >>= \x ->
|
||||
return (\o -> o{ optSyntaxDefinitions = map unpack x })
|
||||
return (\o -> o{ optSyntaxDefinitions =
|
||||
optSyntaxDefinitions o <> map unpack x })
|
||||
"top-level-division" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optTopLevelDivision = x })
|
||||
"html-math-method" ->
|
||||
|
@ -238,7 +253,8 @@ doOpt (k',v) = do
|
|||
parseYAML v >>= \x ->
|
||||
return (\o -> o{ optEpubMetadata = unpack <$> x })
|
||||
"epub-fonts" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optEpubFonts = map unpack x })
|
||||
parseYAML v >>= \x -> return (\o -> o{ optEpubFonts = optEpubFonts o <>
|
||||
map unpack x })
|
||||
"epub-chapter-level" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optEpubChapterLevel = x })
|
||||
"epub-cover-image" ->
|
||||
|
@ -269,7 +285,7 @@ doOpt (k',v) = do
|
|||
"columns" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optColumns = x })
|
||||
"filters" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optFilters = x })
|
||||
parseYAML v >>= \x -> return (\o -> o{ optFilters = optFilters o <> x })
|
||||
"email-obfuscation" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optEmailObfuscation = x })
|
||||
"identifier-prefix" ->
|
||||
|
@ -316,29 +332,37 @@ doOpt (k',v) = do
|
|||
"title-prefix" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optTitlePrefix = x })
|
||||
"css" ->
|
||||
(parseYAML v >>= \x -> return (\o -> o{ optCss = map unpack x }))
|
||||
(parseYAML v >>= \x -> return (\o -> o{ optCss = optCss o <>
|
||||
map unpack x }))
|
||||
<|>
|
||||
(parseYAML v >>= \x -> return (\o -> o{ optCss = [unpack x] }))
|
||||
(parseYAML v >>= \x -> return (\o -> o{ optCss = optCss o <>
|
||||
[unpack x] }))
|
||||
"ipynb-output" ->
|
||||
parseYAML v >>= \x -> return (\o -> o{ optIpynbOutput = x })
|
||||
"include-before-body" ->
|
||||
(parseYAML v >>= \x ->
|
||||
return (\o -> o{ optIncludeBeforeBody = map unpack x }))
|
||||
return (\o -> o{ optIncludeBeforeBody =
|
||||
optIncludeBeforeBody o <> map unpack x }))
|
||||
<|>
|
||||
(parseYAML v >>= \x ->
|
||||
return (\o -> o{ optIncludeBeforeBody = [unpack x] }))
|
||||
return (\o -> o{ optIncludeBeforeBody =
|
||||
optIncludeBeforeBody o <> [unpack x] }))
|
||||
"include-after-body" ->
|
||||
(parseYAML v >>= \x ->
|
||||
return (\o -> o{ optIncludeAfterBody = map unpack x }))
|
||||
return (\o -> o{ optIncludeAfterBody =
|
||||
optIncludeAfterBody o <> map unpack x }))
|
||||
<|>
|
||||
(parseYAML v >>= \x ->
|
||||
return (\o -> o{ optIncludeAfterBody = [unpack x] }))
|
||||
return (\o -> o{ optIncludeAfterBody =
|
||||
optIncludeAfterBody o <> [unpack x] }))
|
||||
"include-in-header" ->
|
||||
(parseYAML v >>= \x ->
|
||||
return (\o -> o{ optIncludeInHeader = map unpack x }))
|
||||
return (\o -> o{ optIncludeInHeader =
|
||||
optIncludeInHeader o <> map unpack x }))
|
||||
<|>
|
||||
(parseYAML v >>= \x ->
|
||||
return (\o -> o{ optIncludeInHeader = [unpack x] }))
|
||||
return (\o -> o{ optIncludeInHeader =
|
||||
optIncludeInHeader o <> [unpack x] }))
|
||||
"resource-path" ->
|
||||
parseYAML v >>= \x ->
|
||||
return (\o -> o{ optResourcePath = map unpack x })
|
||||
|
|
Loading…
Add table
Reference in a new issue