Shared addMetaField: if old and new values both lists, concatenate.

This commit is contained in:
John MacFarlane 2014-05-12 13:05:42 -07:00
parent 06edff7402
commit 2348f07b11

View file

@ -564,8 +564,10 @@ addMetaField :: ToMetaValue a
-> Meta
addMetaField key val (Meta meta) =
Meta $ M.insertWith combine key (toMetaValue val) meta
where combine newval (MetaList xs) = MetaList (xs ++ [newval])
where combine newval (MetaList xs) = MetaList (xs ++ tolist newval)
combine newval x = MetaList [x, newval]
tolist (MetaList ys) = ys
tolist y = [y]
-- | Create 'Meta' from old-style title, authors, date. This is
-- provided to ease the transition from the old API.