diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-10-05 21:15:20 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-10-05 21:15:20 -0700 |
commit | 3e7ca707c9514c30a02786e45646ce0c6eb3abe7 (patch) | |
tree | 1c3ce3ac1bdabe484c2533ebd260ade013464536 /src/Text/Pandoc/Citeproc | |
parent | 6a32ea71ea9af8613b8585e874fef8d5f29665fa (diff) | |
download | pandoc-3e7ca707c9514c30a02786e45646ce0c6eb3abe7.tar.gz |
Removed the idpred from metaValueToReference.
This isn't really necessary; we do filtering at other points now.
Diffstat (limited to 'src/Text/Pandoc/Citeproc')
-rw-r--r-- | src/Text/Pandoc/Citeproc/MetaValue.hs | 28 |
1 files changed, 10 insertions, 18 deletions
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 |