citation-resolve 0.1.0.0 → 0.2.0.0
raw patch · 3 files changed
+31/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.CSL.Input.Identifier: readID :: Resolver Reference
+ Text.CSL.Input.Identifier.Internal: readID :: Resolver Reference
Files
- Text/CSL/Input/Identifier.hs +1/−1
- Text/CSL/Input/Identifier/Internal.hs +29/−1
- citation-resolve.cabal +1/−1
Text/CSL/Input/Identifier.hs view
@@ -11,7 +11,7 @@ module Text.CSL.Input.Identifier- (readDOI, readArXiv, readISBN )+ (readID, readDOI, readArXiv, readISBN ) where
Text/CSL/Input/Identifier/Internal.hs view
@@ -12,6 +12,8 @@ import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Resource (runResourceT) import qualified Data.ByteString.Char8 as BS+import Data.Char (toLower)+import Data.List (span) import qualified Data.Text as Text import Database.Persist import Database.Persist.TH@@ -29,7 +31,7 @@ -- $setup--- >>> import Control.Applicative((<$>))+-- >>> import Control.Applicative((<$>), (<*>)) -- >>> import Data.Either.Utils(forceEither) -- >>> import Text.CSL @@ -81,6 +83,32 @@ [r] -> return $ Right r [] -> return $ Left $ src ++ " returned no reference." _ -> return $ Left $ src ++ " returned multiple references."+++-- | Multi-purpose reference ID resolver. Resolve 'String' starting+-- with "arXiv:", "isbn:", "doi:" to 'Reference' .+-- +-- >>> (==) <$> readArXiv "1204.4779" <*> readID "arXiv:1204.4779"+-- True+-- >>> (==) <$> readDOI "10.1088/1749-4699/5/1/015003" <*> readID "doi:10.1088/1749-4699/5/1/015003"+-- True+-- >>> (==) <$> readISBN "9780199233212" <*> readID "isbn:9780199233212"+-- True++++readID :: Resolver Reference+readID str + | idId == "arxiv" = readArXiv addr+ | idId == "doi" = readDOI addr+ | idId == "isbn" = readISBN addr+ | otherwise = return $ Left $ "Unknown identifier type: " ++ str+ where+ (h,t) = span (/=':') str+ idId = map toLower h+ addr = drop 1 t+ + -- | resolve a DOI to a 'Reference'.
citation-resolve.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: citation-resolve-version: 0.1.0.0+version: 0.2.0.0 synopsis: convert document IDs such as DOI, ISBN, arXiv ID to bibliographic reference. description: This modules provides a way to convert document identifiers, such