Removed the idpred from metaValueToReference.
This isn't really necessary; we do filtering at other points now.
This commit is contained in:
parent
6a32ea71ea
commit
3e7ca707c9
3 changed files with 13 additions and 22 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue