citeproc 0.2.0.1 → 0.3
raw patch · 5 files changed
+30/−8 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Citeproc.Types: makeReferenceMap :: [Reference a] -> ReferenceMap a
+ Citeproc.Types: makeReferenceMap :: [Reference a] -> ([Reference a], ReferenceMap a)
Files
- CHANGELOG.md +8/−0
- citeproc.cabal +1/−1
- man/citeproc.1 +2/−2
- src/Citeproc/Eval.hs +4/−2
- src/Citeproc/Types.hs +15/−3
CHANGELOG.md view
@@ -1,5 +1,13 @@ # citeproc changelog +## 0.3++ * Change `makeReferenceMap` to return a cleaned-up list of+ references as well as a reference map. The cleanup-up list+ removes references with duplicate ids. When there are multiple+ references with the same id, the last one is included and+ the others discarded. [API change]+ ## 0.2.0.1 * FromJSON for Name: make straight quotes curly.
citeproc.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: citeproc-version: 0.2.0.1+version: 0.3 synopsis: Generates citations and bibliography from CSL styles. description: citeproc parses CSL style files and uses them to generate a list of formatted citations and bibliography
man/citeproc.1 view
@@ -1,6 +1,6 @@-.\" Automatically generated by Pandoc 2.11.2+.\" Automatically generated by Pandoc 2.11.3 .\"-.TH "citeproc" "1" "" "citeproc 0.2.0.1" ""+.TH "citeproc" "1" "" "citeproc 0.3" "" .hy .SH NAME .PP
src/Citeproc/Eval.hs view
@@ -86,9 +86,11 @@ -> [Citation a] -- ^ List of citations. -> ([Output a], [(Text, Output a)], [Text]) -- ^ (citations, (id, bibentry) pairs, warnings)-evalStyle style mblang refs citations =+evalStyle style mblang refs' citations = (citationOs, bibliographyOs, Set.toList warnings) where+ (refs, refmap) = makeReferenceMap refs'+ ((citationOs, bibliographyOs), warnings) = evalRWS go Context { contextLocale = mergeLocales mblang style@@ -105,7 +107,7 @@ { stateVarCount = VarCount 0 0 , stateLastCitedMap = mempty , stateNoteMap = mempty- , stateRefMap = makeReferenceMap refs+ , stateRefMap = refmap , stateReference = Reference mempty mempty Nothing mempty , stateUsedYearSuffix = False }
src/Citeproc/Types.hs view
@@ -103,6 +103,7 @@ , Inputs(..) ) where+import qualified Data.Set as Set import qualified Data.Map as M import qualified Data.Text.Read as TR import qualified Data.Scientific as S@@ -1061,9 +1062,20 @@ ReferenceMap { unReferenceMap :: M.Map ItemId (Reference a) } deriving (Show) -makeReferenceMap :: [Reference a] -> ReferenceMap a-makeReferenceMap refs =- ReferenceMap (M.fromList (map (\r -> (referenceId r, r)) refs))+-- | Returns a pair consisting of the cleaned up list of+-- references and a reference map. If the original reference+-- list contains items with the same id, then the one that+-- occurs last in the list is retained, and the others are+-- omittedfrom the cleaned-up list.+makeReferenceMap :: [Reference a] -> ([Reference a], ReferenceMap a)+makeReferenceMap = snd . foldr go (mempty, ([], ReferenceMap mempty))+ where+ go ref (ids, (rs, ReferenceMap refmap)) =+ let rid = referenceId ref+ in if Set.member rid ids+ then (ids, (rs, ReferenceMap refmap))+ else (Set.insert rid ids,+ (ref:rs, ReferenceMap (M.insert rid ref refmap))) lookupReference :: ItemId -> ReferenceMap a -> Maybe (Reference a) lookupReference ident (ReferenceMap m) = M.lookup ident m