From 71fab252d5d6066fb6be585246738773121bee5f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 22 Dec 2019 22:01:30 -0800 Subject: 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. --- src/Text/Pandoc/App/Opt.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Text') 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 }) -- cgit v1.2.3