citeproc-hs 0.3.7 → 0.3.8
raw patch · 9 files changed
+92/−62 lines, 9 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Text.CSL: director :: Reference -> [Agent]
+ Text.CSL.Reference: director :: Reference -> [Agent]
+ Text.CSL.Style: ODate :: [Output] -> Output
- Text.CSL: Reference :: String -> RefType -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [RefDate] -> [RefDate] -> [RefDate] -> [RefDate] -> [RefDate] -> [RefDate] -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> [String] -> CNum -> Int -> String -> Reference
+ Text.CSL: Reference :: String -> RefType -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [RefDate] -> [RefDate] -> [RefDate] -> [RefDate] -> [RefDate] -> [RefDate] -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> [String] -> CNum -> Int -> String -> Reference
- Text.CSL.Input.MODS: xpAgents :: PU (([Agent], [Agent], [Agent]), ([Agent], [Agent], [Agent]), ([Agent], [Agent], [Agent], [Agent]))
+ Text.CSL.Input.MODS: xpAgents :: PU (([Agent], [Agent], [Agent]), ([Agent], [Agent], [Agent], [Agent]), ([Agent], [Agent], [Agent], [Agent]))
- Text.CSL.Input.MODS: xpTitle :: PU String
+ Text.CSL.Input.MODS: xpTitle :: PU (String, String)
- Text.CSL.Reference: Reference :: String -> RefType -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [RefDate] -> [RefDate] -> [RefDate] -> [RefDate] -> [RefDate] -> [RefDate] -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> [String] -> CNum -> Int -> String -> Reference
+ Text.CSL.Reference: Reference :: String -> RefType -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [Agent] -> [RefDate] -> [RefDate] -> [RefDate] -> [RefDate] -> [RefDate] -> [RefDate] -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> String -> [String] -> CNum -> Int -> String -> Reference
Files
- citeproc-hs.cabal +1/−1
- src/Text/CSL/Eval/Date.hs +1/−1
- src/Text/CSL/Eval/Names.hs +12/−9
- src/Text/CSL/Input/Bibutils.hs +0/−1
- src/Text/CSL/Input/MODS.hs +60/−41
- src/Text/CSL/Output/Pandoc.hs +3/−2
- src/Text/CSL/Reference.hs +3/−0
- src/Text/CSL/Style.hs +12/−7
- test/createTest.hs +0/−0
citeproc-hs.cabal view
@@ -1,5 +1,5 @@ name: citeproc-hs-version: 0.3.7+version: 0.3.8 homepage: http://gorgias.mine.nu/repos/citeproc-hs/ synopsis: A Citation Style Language implementation in Haskell
src/Text/CSL/Eval/Date.hs view
@@ -77,7 +77,7 @@ formatDate :: EvalMode -> String -> [TermMap] -> [DatePart] -> [RefDate] -> [Output] formatDate em k tm dp date | [d] <- date = concatMap (formatDatePart False d) dp- | (a:b:_) <- date = concat $ (start a b ++ end a b ++ coda b)+ | (a:b:_) <- date = return . ODate . concat $ (start a b ++ end a b ++ coda b) | otherwise = [] where start a b = map (formatDatePart False a) . init . diff a b $ dp
src/Text/CSL/Eval/Names.hs view
@@ -117,16 +117,19 @@ return res | EtAl fm t <- n = do- et <- gets etal o <- gets (options . env)- let i = length as - length et- t' = if null t then "et-al" else t- r <- mapM (et_al o False t' fm del) [i .. length as]- let (r',r'') = case r of- (x:xs) -> ( x,xs ++ [])- _ -> ([], [])- updateEtal r''- return r'+ if (getOptionVal "et-al-min" o == [])+ then return []+ else do+ et <- gets etal+ let i = length as - length et+ t' = if null t then "et-al" else t+ r <- mapM (et_al o False t' fm del) [i .. length as]+ let (r',r'') = case r of+ (x:xs) -> ( x,xs ++ [])+ _ -> ([], [])+ updateEtal r''+ return r' | otherwise = return [] where
src/Text/CSL/Input/Bibutils.hs view
@@ -115,7 +115,6 @@ param <- bibl_initparams bin mods_out "hs-bibutils" bibl <- bibl_init unsetBOM param- setNoSplitTitle param setCharsetIn param bibl_charset_unicode setCharsetOut param bibl_charset_unicode _ <- bibl_read param bibl fin
src/Text/CSL/Input/MODS.hs view
@@ -43,15 +43,16 @@ xpReference = xpWrap ( \ ( ref , (ck,ty,ti,i,d)- ,((au,ed,tr),(re,it,pu'),(co,ce,dg,om))+ ,((au,ed,tr),(re,it,pu',dr),(co,ce,dg,om)) ,((di',pg,vl,is),(nu,sc,ch)) , (di,ac,pu,pp,et) , ((ac',uri),no) ) ->- ref { refId = ck `betterThen` take 10 (concat $ words ti)+ ref { refId = ck `betterThen` take 10 (concat . words $ fst ti) , refType = if ty /= NoType then ty else if refType ref == Book then Chapter else refType ref- , title = ti+ , title = fst ti+ , titleShort = snd ti , author = au , editor = ed `betterThen` editor ref , edition = et `betterThen` edition ref@@ -59,6 +60,7 @@ , recipient = re `betterThen` recipient ref , interviewer = it `betterThen` interviewer ref , composer = co `betterThen` composer ref+ , director = dr `betterThen` director ref , collectionEditor = ce `betterThen` collectionEditor ref , publisherPlace = pp `betterThen` publisherPlace ref , containerAuthor = containerAuthor ref@@ -82,9 +84,9 @@ `betterThen` fromAgent om } , \r -> ( r- , (refId r, refType r, title r, isbn r, doi r)+ , (refId r, refType r, (title r, titleShort r), isbn r, doi r) ,((author r, editor r, translator r)- ,(recipient r, interviewer r, emptyAgents )+ ,(recipient r, interviewer r, emptyAgents, director r) ,(composer r, collectionEditor r, emptyAgents, emptyAgents)) ,((issued r, page r, volume r, issue r) ,(number r, section r, chapterNumber r))@@ -130,37 +132,39 @@ xpRelatedItem = xpIElem "relatedItem" . xpAddFixedAttr "type" "host" $ xpWrap ( \( (ty,ct)- ,((ca,ed,tr),(re,it,pu'),(co,ce,dg,om))+ ,((ca,ed,tr),(re,it,pu',dr),(co,ce,dg,om)) ,((di,pg,vl,is),(nu,sc,ch)) , (di',ac,pu,pp,et) ) ->- emptyReference { refType = ty- , containerAuthor = ca- , containerTitle = ct- , editor = ed- , edition = et- , translator = tr- , recipient = re- , interviewer = it- , publisherPlace = pp- , composer = co- , collectionEditor = ce- , issued = di `betterThen` di'- , accessed = ac- , page = pg- , volume = vl- , issue = is `betterThen` nu- , number = nu- , section = sc- , chapterNumber = ch- , publisher = fromAgent $ pu `betterThen` pu' `betterThen`- dg `betterThen` om+ emptyReference { refType = ty+ , containerAuthor = ca+ , containerTitle = fst ct+ , containerTitleShort = snd ct+ , editor = ed+ , edition = et+ , translator = tr+ , recipient = re+ , interviewer = it+ , publisherPlace = pp+ , composer = co+ , director = dr+ , collectionEditor = ce+ , issued = di `betterThen` di'+ , accessed = ac+ , page = pg+ , volume = vl+ , issue = is `betterThen` nu+ , number = nu+ , section = sc+ , chapterNumber = ch+ , publisher = fromAgent $ pu `betterThen` pu' `betterThen`+ dg `betterThen` om }- , \r -> ( (refType r, containerTitle r)+ , \r -> ( (refType r, (containerTitle r, containerTitleShort r)) ,((containerAuthor r, editor r, translator r)- ,(recipient r, interviewer r, emptyAgents )- ,(composer r, collectionEditor r, emptyAgents , emptyAgents))+ ,(recipient r, interviewer r, emptyAgents, director r)+ ,(composer r, collectionEditor r, emptyAgents, emptyAgents)) ,((issued r, page r, volume r, issue r) ,(number r, section r, chapterNumber r)) , (issued r, accessed r,emptyAgents, publisherPlace r, edition r)@@ -168,24 +172,33 @@ xp4Tuple (xpPair xpRefType xpTitle) xpAgents xpPart xpOrigin --- FIXME: join title and subtitle correctly: usare Title per shortTitle.-xpTitle :: PU String+xpTitle :: PU (String,String) xpTitle- = xpWrap (uncurry (<+>), \s -> (s,[])) $- xpIElem "titleInfo" $- xpPair (xpIElem "title" xpText0)- (xpDefault [] $ xpIElem "subTitle" xpText0)+ = xpWrap (\((a,b),c) -> createTitle a b c , \s -> (s,[])) $+ xpPair (xpIElem "titleInfo" $+ xpPair (xpIElem "title" xpText0)+ (xpDefault [] $ xpIElem "subTitle" xpText0))+ (xpDefault [] $ xpIElem "titleInfo" $+ xpAddFixedAttr "type" "abbreviated" $ xpElem "title" xpText0)+ where+ createTitle [] [] [] = ([],[])+ createTitle s [] [] = (s ,[])+ createTitle s [] ab = (s ,ab)+ createTitle s sub [] = (s ++ colon s ++ sub, s)+ createTitle s sub ab = (s ++ colon s ++ sub, ab)+ colon s = if last s == '!' || last s == '?' then " " else ": " xpAgents :: PU (([Agent],[Agent],[Agent])- ,([Agent],[Agent],[Agent])+ ,([Agent],[Agent],[Agent],[Agent]) ,([Agent],[Agent],[Agent],[Agent])) xpAgents = xpTriple (xpTriple (xpAgent "author" "aut") (xpAgent "editor" "edt") (xpAgent "translator" "trl"))- (xpTriple (xpAgent "recipient" "rcp")+ (xp4Tuple (xpAgent "recipient" "rcp") (xpAgent "interviewer" "ivr")- (xpAgent "publisher" "pbl"))+ (xpAgent "publisher" "pbl")+ (xpAgent "director" "drt")) (xp4Tuple (xpAgent "composer" "cmp") (xpAgent "collector" "xol") (xpAgent "degree grantor" "dgg")@@ -206,7 +219,7 @@ personal = xpWrap ( uncurry parseName , \(Agent gn _ _ fn _ _ _) -> (gn,fn)) $ xpAddFixedAttr "type" "personal" xpNameData- others =xpWrap (\s -> Agent [] [] [] [] [] s False, undefined) $+ others = xpWrap (\s -> Agent [] [] [] [] [] s False, undefined) $ xpElem "namePart" xpText0 -- | "von Hicks,! Jr., Michael" or "la Martine,! III, Martin B. de" or@@ -276,6 +289,7 @@ , xpWrap (Volume, show) $ xp "volume" , xpWrap (Issue, show) $ xp "issue" , xpWrap (Number, show) $ xp "number"+ , xpWrap (Number, show) $ xp "report number" , xpWrap (Section, show) $ xp "section" , xpWrap (ChapterNr,show) $ xp "chapter" ]@@ -346,6 +360,7 @@ , ( "book chapter", Chapter ) , ( "periodical", ArticleJournal ) , ( "newspaper", ArticleNewspaper )+ , ( "magazine article", ArticleNewspaper ) , ( "encyclopedia", EntryEncyclopedia) , ( "conference publication", PaperConference ) , ( "academic journal", ArticleJournal )@@ -353,7 +368,11 @@ , ( "legal case and case notes", LegalCase ) , ( "legislation", Legislation ) , ( "instruction", Book )- , ( "motion picutre", MotionPicture )+ , ( "motion picture", MotionPicture )+ , ( "film", MotionPicture )+ , ( "tvBroadcast", MotionPicture )+ , ( "videoRecording", MotionPicture )+ , ( "videorecording", MotionPicture ) , ( "patent", Patent ) , ( "Ph.D. thesis", Thesis ) , ( "Masters thesis", Thesis )
src/Text/CSL/Output/Pandoc.hs view
@@ -87,8 +87,9 @@ toCap s = if s /= [] then toUpper (head s) : map toLower (tail s) else [] toTitleCap s = if isShortWord s then toUpper (head s) : tail s else s- isShortWord s = not $ s `elem` ["a","an","and","the","at","by","for","of"- ,"in","up","on","as","but","if","or","nor"]+ isShortWord s = not $ s `elem` ["a","an","and","as","at","but","by","down","for","from"+ ,"in","into","nor","of","on","onto","or","over","so"+ ,"the","till","to","up","via","with","yet"] text_case _ [] = [] text_case fm a@(i:is) | noCase fm = [escape "nocase" a]
src/Text/CSL/Reference.hs view
@@ -54,6 +54,7 @@ | Just v <- fromValue val :: Maybe [RefDate] = v /= [] | Just v <- fromValue val :: Maybe Int = v /= 0 | Just v <- fromValue val :: Maybe CNum = v /= 0+ | Just _ <- fromValue val :: Maybe Empty = True | otherwise = False data Empty = Empty deriving ( Typeable, Data )@@ -138,6 +139,7 @@ , recipient :: [Agent] , interviewer :: [Agent] , composer :: [Agent]+ , director :: [Agent] , illustrator :: [Agent] , originalAuthor :: [Agent] , containerAuthor :: [Agent]@@ -219,6 +221,7 @@ , recipient = [] , interviewer = [] , composer = []+ , director = [] , illustrator = [] , originalAuthor = [] , containerAuthor = []
src/Text/CSL/Style.hs view
@@ -324,6 +324,7 @@ | OStr String Formatting -- ^ A simple 'String' | ONum Int Formatting -- ^ A number (used to count contributors) | OCitNum Int Formatting -- ^ The citation number+ | ODate [Output] -- ^ A (possibly) ranged date | OYear String String Formatting -- ^ The year and the citeId | OYearSuf String String [Output] Formatting -- ^ The year suffix, the citeId and a holder for collision data | OName String [Output] [[Output]] Formatting -- ^ A (family) name with the list of given names.@@ -443,6 +444,7 @@ | ODel s <- o = FDel s | OStr [] _ <- o = FNull | OStr s f <- o = FS s f+ | ODate os <- o = FO emptyFormatting (format os) | OYear s _ f <- o = FS s f | OYearSuf s _ _ f <- o = FS s f | ONum i f <- o = FS (show i) f@@ -500,13 +502,16 @@ -- | Add the year suffix to the year. Needed for disambiguation. addYearSuffix :: Output -> Output addYearSuffix o- | OYear y k f <- o = Output [OYear y k emptyFormatting,OYearSuf [] k [] emptyFormatting] f- | Output (x:xs) f <- o = if or $ map hasYearSuf (x : xs)- then Output (x : xs) f- else if hasYear x- then Output (addYearSuffix x : xs) f- else Output (x : [addYearSuffix $ Output xs emptyFormatting]) f- | otherwise = o+ | OYear y k f <- o = Output [OYear y k emptyFormatting,OYearSuf [] k [] emptyFormatting] f+ | ODate (x:xs) <- o = if or $ map hasYear xs+ then Output (x : [addYearSuffix $ ODate xs]) emptyFormatting+ else addYearSuffix (Output (x:xs) emptyFormatting)+ | Output (x:xs) f <- o = if or $ map hasYearSuf (x : xs)+ then Output (x : xs) f+ else if hasYear x+ then Output (addYearSuffix x : xs) f+ else Output (x : [addYearSuffix $ Output xs emptyFormatting]) f+ | otherwise = o hasYear :: Output -> Bool hasYear = not . null . query getYear
test/createTest.hs view