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.
This commit is contained in:
John MacFarlane 2019-12-22 22:01:30 -08:00
parent 7ba55d7405
commit 71fab252d5

View file

@ -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 })