summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-05 09:28:44 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-05 09:28:44 +0100
commit7fc6919f9039a3c71028b807d4372f18cf35bee8 (patch)
tree4a9ec29b473231ce73e7aa0c0687d7d36afe601b /src/Text/Pandoc
parentba3ee62323644134f2a5dd3277e3349d3681111a (diff)
Markdown reader: Fixed regression on left-biased union for metadata.
When multiple YAML metadata blocks are used, and two define the same field, the value defined first takes precedence, according to the manual. This was changed briefly in ba3ee62323644134f2a5dd3277e3349d3681111a. This commit reverts to the original behavior and adds a test case.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 42d719e28..4790f83ff 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -254,12 +254,15 @@ yamlMetaBlock = try $ do
then return ()
else do
v' <- yamlToMeta v
- updateState $ \st ->
- let smeta = stateMeta' st
- in st{ stateMeta' =
- (do v'' <- v'
- m <- smeta
- return $ B.setMeta (T.unpack k) v'' m)}
+ let k' = T.unpack k
+ updateState $ \st -> st{ stateMeta' =
+ (do m <- stateMeta' st
+ -- if there's already a value, leave it unchanged
+ case lookupMeta k' m of
+ Just _ -> return m
+ Nothing -> do
+ v'' <- v'
+ return $ B.setMeta (T.unpack k) v'' m)}
) alist
Right Yaml.Null -> return ()
Right _ -> do