aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Citeproc.hs5
-rw-r--r--src/Text/Pandoc/Citeproc/MetaValue.hs28
-rw-r--r--src/Text/Pandoc/Writers/CslJson.hs2
3 files changed, 13 insertions, 22 deletions
diff --git a/src/Text/Pandoc/Citeproc.hs b/src/Text/Pandoc/Citeproc.hs
index 4f92cf8ca..56eeabbbf 100644
--- a/src/Text/Pandoc/Citeproc.hs
+++ b/src/Text/Pandoc/Citeproc.hs
@@ -107,8 +107,7 @@ processCitations (Pandoc meta bs) = do
c `Set.member` nocites)
refs <- map (linkifyVariables . legacyDateRanges) <$>
case lookupMeta "references" meta of
- Just (MetaList rs) -> return $
- mapMaybe (metaValueToReference idpred) rs
+ Just (MetaList rs) -> return $ mapMaybe metaValueToReference rs
_ ->
case lookupMeta "bibliography" meta of
Just (MetaList xs) ->
@@ -216,7 +215,7 @@ getRefs locale format idpred raw =
rs <- yamlToRefs idpred
def{ readerExtensions = pandocExtensions }
(L.fromStrict raw)
- return $ mapMaybe (metaValueToReference idpred . MetaMap) rs
+ return $ mapMaybe (metaValueToReference . MetaMap) rs
-- localized quotes
convertQuotes :: Locale -> Inline -> Inline
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
diff --git a/src/Text/Pandoc/Writers/CslJson.hs b/src/Text/Pandoc/Writers/CslJson.hs
index 4f4fad212..3a8f6f5b1 100644
--- a/src/Text/Pandoc/Writers/CslJson.hs
+++ b/src/Text/Pandoc/Writers/CslJson.hs
@@ -48,7 +48,7 @@ writeCslJson _opts (Pandoc meta _) = do
Right l -> return l
case lookupMeta "references" meta of
Just (MetaList rs) -> return $ (UTF8.toText $
- toCslJson locale (mapMaybe (metaValueToReference (const True)) rs))
+ toCslJson locale (mapMaybe metaValueToReference rs))
<> "\n"
_ -> throwError $ PandocAppError "No references field"