packages feed

bibtex 0.0.4 → 0.0.5

raw patch · 2 files changed

+71/−2 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Text.BibTeX.Parse: skippingLeadingSpace :: Parser a -> Parser a

Files

bibtex.cabal view
@@ -1,5 +1,5 @@ Name:             bibtex-Version:          0.0.4+Version:          0.0.5 License:          BSD3 License-File:     LICENSE Author:           Henning Thielemann <haskell@henning-thielemann.de>@@ -74,7 +74,7 @@ Source-Repository this   type:     darcs   location: http://code.haskell.org/~thielema/bibtex/-  tag:      0.0.4+  tag:      0.0.5  Flag base2   description: Choose the new smaller, split-up base package.
src/Text/BibTeX/Parse.hs view
@@ -13,17 +13,46 @@ import Data.String.HT (trim, )  +{- |+Beware that this and all other parsers do not accept leading spaces,+cf. 'skippingSpace'.+That is when encountering leading white spaces+the parser will just return an empty list.+If you want to parse a file that contains entirely of BibTeX data+you better call @skippingLeadingSpace file@ instead.+However, the @file@ parser is more combinable+and can be used for files that contain both BibTeX and other data+or it can be used for automated filetype checking.+-} file :: Parser [Entry.T] file =    fmap catMaybes $    Parsec.many       (skippingSpace (fmap Just entry <|> fmap (const Nothing) comment)) +{- |+Parse a line that starts with a hash like++> # this is a comment++.+-} comment :: Parser String comment =    do Parsec.char '#'       fmap trim $ Parsec.manyTill Parsec.anyChar Parsec.newline +{- |+Parse a BibTeX entry like++> @article{author2010title,+>   author = {Firstname Surname},+>   title = {Title},+>   year = {2010},+> }++.+-} entry :: Parser Entry.T entry =    do Parsec.char '@'@@ -35,7 +64,13 @@       skippingSpace (Parsec.char '}')       return (Entry.Cons entryType bibId assigns) +{- |+Parse an assignment like +> author = {Firstname Surname}++.+-} assignment :: Parser (String, String) assignment =    do field <- skippingSpace bibIdentifier@@ -43,16 +78,40 @@       val <- skippingSpace value       return (field, trim val) +{- |+Parse an assignment like++> 2010++or++> {Firstname Surname}++or++> "Firstname Surname"++.+-} value :: Parser String value =    Parsec.many1 Parsec.digit <|>    Parsec.between (Parsec.char '{') (Parsec.char '}') (texSequence '}') <|>    Parsec.between (Parsec.char '"') (Parsec.char '"') (texSequence '"') +{- |+Parse a sequence of 'texBlock's until the occurrence of a closing character.+The closing character is not part of the result.+-} texSequence :: Char -> Parser String texSequence closeChar =    liftM concat (Parsec.many (texBlock closeChar)) +{- |+Parse a single character like @a@,+a LaTeX macro call like @\\alpha@+or a block enclosed in curly braces like @{\\\"{a}bc}@.+-} texBlock :: Char -> Parser String texBlock closeChar =    liftM3 (\open body close -> open : body ++ close : [])@@ -62,12 +121,18 @@        Parsec.oneOf "{}'`^&%\".,~# " <|> Parsec.letter] <|>    fmap (:[]) (Parsec.noneOf [closeChar]) +{- |+Parse a type of a BibTeX entry like @article@.+-} identifier :: Parser String identifier =    liftM2 (:)       Parsec.letter       (Parsec.many Parsec.alphaNum) +{- |+Parse a name of a BibTeX entry like @author2010title@.+-} bibIdentifier :: Parser String bibIdentifier =    liftM2 (:)@@ -88,6 +153,10 @@    do x <- p       Parsec.skipMany Parsec.space       return x++skippingLeadingSpace :: Parser a -> Parser a+skippingLeadingSpace p =+   Parsec.skipMany Parsec.space >> p