From 3e7ca707c9514c30a02786e45646ce0c6eb3abe7 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 5 Oct 2020 21:15:20 -0700 Subject: Removed the idpred from metaValueToReference. This isn't really necessary; we do filtering at other points now. --- src/Text/Pandoc/Citeproc/MetaValue.hs | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'src/Text/Pandoc/Citeproc') diff --git a/src/Text/Pandoc/Citeproc/MetaValue.hs b/src/Text/Pandoc/Citeproc/MetaValue.hs index 13bba664d..17d5da327 100644 --- a/src/Text/Pandoc/Citeproc/MetaValue.hs +++ b/src/Text/Pandoc/Citeproc/MetaValue.hs @@ -102,27 +102,19 @@ dateToMetaValue date = | otherwise -> printf "%04d" y _ -> mempty -metaValueToReference :: (Text -> Bool) -- ^ predicate on IDs to include - -> MetaValue +metaValueToReference :: MetaValue -> Maybe (Reference Inlines) -metaValueToReference idpred (MetaMap m) = do +metaValueToReference (MetaMap m) = do let m' = M.mapKeys normalizeKey m id' <- M.lookup "id" m' >>= metaValueToText - 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 + 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 metaValueToVal :: Text -> MetaValue -> Val Inlines metaValueToVal k v -- cgit v1.2.3