aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/App
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-12-22 22:01:30 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2019-12-22 22:01:30 -0800
commit71fab252d5d6066fb6be585246738773121bee5f (patch)
treef9dd1d50bce313e65bf9d37e9970f4a0c9f679d5 /src/Text/Pandoc/App
parent7ba55d74057c58b1108afb2404ffa6f2937ebb96 (diff)
downloadpandoc-71fab252d5d6066fb6be585246738773121bee5f.tar.gz
Ensure that later default file values for `variable` replace earlier ones.
The semigroup instance for doctemplates Context does a left-biased union on the underlying Map. That means that if you union `{a: 1}` and `{a: 2}`, you get `{a: 1}`. This commit causes pandoc to do the operation in the opposite order, so that later default files take precedence in the values they assign to keys. See #5988.
Diffstat (limited to 'src/Text/Pandoc/App')
-rw-r--r--src/Text/Pandoc/App/Opt.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/Text/Pandoc/App/Opt.hs b/src/Text/Pandoc/App/Opt.hs
index 4f54bad48..a753d6ab3 100644
--- a/src/Text/Pandoc/App/Opt.hs
+++ b/src/Text/Pandoc/App/Opt.hs
@@ -180,7 +180,9 @@ doOpt (k',v) = do
parseYAML v >>= \x -> return (\o -> o{ optTemplate = unpack <$> x })
"variables" ->
parseYAML v >>= \x -> return (\o -> o{ optVariables =
- optVariables o <> x })
+ x <> optVariables o })
+ -- Note: x comes first because <> for Context is left-biased union
+ -- and we want to favor later default files. See #5988.
"metadata" ->
parseYAML v >>= \x -> return (\o -> o{ optMetadata = optMetadata o <>
contextToMeta x })