From e6e3823982cb9755b7cb4727fb08171eed5b4332 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 25 Feb 2016 14:26:47 +0100 Subject: Accept trailing newlines --- bbcode/bbcode.cabal | 2 +- bbcode/bbcode.nix | 2 +- bbcode/src/Text/BBCode.hs | 4 ++-- bbcode/test/Text/BBCodeSpec.hs | 6 ++++++ 4 files changed, 10 insertions(+), 4 deletions(-) (limited to 'bbcode') diff --git a/bbcode/bbcode.cabal b/bbcode/bbcode.cabal index ad8bb5a..5ef4890 100644 --- a/bbcode/bbcode.cabal +++ b/bbcode/bbcode.cabal @@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: bbcode -version: 3.0.0 +version: 3.1.0 synopsis: A parser for bbcode -- description: homepage: http://dirty-haskell.org/tags/thermoprint.html diff --git a/bbcode/bbcode.nix b/bbcode/bbcode.nix index 6426b0b..30a6b49 100644 --- a/bbcode/bbcode.nix +++ b/bbcode/bbcode.nix @@ -3,7 +3,7 @@ }: mkDerivation { pname = "bbcode"; - version = "3.0.0"; + version = "3.1.0"; src = ./.; libraryHaskellDepends = [ attoparsec base case-insensitive containers rosezipper text diff --git a/bbcode/src/Text/BBCode.hs b/bbcode/src/Text/BBCode.hs index d0c9974..f2a9570 100644 --- a/bbcode/src/Text/BBCode.hs +++ b/bbcode/src/Text/BBCode.hs @@ -25,7 +25,7 @@ import Data.Function (on) import Control.Applicative import Text.BBCode.Lexer (BBToken(..), token) -import Data.Attoparsec.Text (parseOnly, endOfInput) +import Data.Attoparsec.Text (parseOnly, endOfInput, endOfLine) import Data.Tree import Data.Tree.Zipper (TreePos, Empty, Full) @@ -72,7 +72,7 @@ instance Exception BBCodeError bbcode :: Text -> Either BBCodeError DomForest -- ^ Parse BBCode -bbcode t = fmap dom $ first LexerError (parseOnly (many token <* endOfInput) t) >>= first TreeError . rose +bbcode t = fmap dom $ first LexerError (parseOnly (many token <* many endOfLine <* endOfInput) t) >>= first TreeError . rose -- | Errors in input encountered during parsing of lexed token-stream data TreeError = MismatchedTags Text Text -- ^ Closing tags label does not match opening tags diff --git a/bbcode/test/Text/BBCodeSpec.hs b/bbcode/test/Text/BBCodeSpec.hs index a6e66b6..4e7ea72 100644 --- a/bbcode/test/Text/BBCodeSpec.hs +++ b/bbcode/test/Text/BBCodeSpec.hs @@ -61,5 +61,11 @@ examples = [ ("[t]test[/t]" , [[Element "b" [] [Content "foo"]], [Element "b" [] [Content "bar"]]]) , ("[b]foo[/b][b]bar[/b]" , [[Element "b" [] [Content "foo"], Element "b" [] [Content "bar"]]]) + , ("[b]foo[/b]\n" + , [[Element "b" [] [Content "foo"]]]) + , ("[b]foo[/b] \n" + , [[Element "b" [] [Content "foo"], Content " "]]) + , ("[b]foo[/b] " + , [[Element "b" [] [Content "foo"], Content " "]]) ] -- cgit v1.2.3