aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Citeproc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Citeproc')
-rw-r--r--src/Text/Pandoc/Citeproc/MetaValue.hs29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Citeproc/MetaValue.hs b/src/Text/Pandoc/Citeproc/MetaValue.hs
index 1b80c879a..13bba664d 100644
--- a/src/Text/Pandoc/Citeproc/MetaValue.hs
+++ b/src/Text/Pandoc/Citeproc/MetaValue.hs
@@ -102,18 +102,27 @@ dateToMetaValue date =
| otherwise -> printf "%04d" y
_ -> mempty
-metaValueToReference :: MetaValue -> Maybe (Reference Inlines)
-metaValueToReference (MetaMap m) = do
+metaValueToReference :: (Text -> Bool) -- ^ predicate on IDs to include
+ -> MetaValue
+ -> Maybe (Reference Inlines)
+metaValueToReference idpred (MetaMap m) = do
let m' = M.mapKeys normalizeKey m
id' <- M.lookup "id" m' >>= metaValueToText
- type' <- (M.lookup "type" m' >>= metaValueToText) <|> pure ""
- let m'' = M.delete "id" $ M.delete "type" m'
- let vars = M.mapKeys toVariable $ M.mapWithKey metaValueToVal m''
- return $ Reference { referenceId = ItemId id'
- , referenceType = type'
- , referenceDisambiguation = Nothing
- , referenceVariables = vars }
-metaValueToReference _ = Nothing
+ let mbotherids =
+ case M.lookup "other-ids" m' of
+ Just (MetaList xs) -> map metaValueToText xs
+ _ -> []
+ if idpred id' || any (maybe False idpred) mbotherids
+ then do
+ type' <- (M.lookup "type" m' >>= metaValueToText) <|> pure ""
+ let m'' = M.delete "id" $ M.delete "type" m'
+ let vars = M.mapKeys toVariable $ M.mapWithKey metaValueToVal m''
+ return $ Reference { referenceId = ItemId id'
+ , referenceType = type'
+ , referenceDisambiguation = Nothing
+ , referenceVariables = vars }
+ else Nothing
+metaValueToReference _ _ = Nothing
metaValueToVal :: Text -> MetaValue -> Val Inlines
metaValueToVal k v