diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-02-25 14:26:47 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-02-25 14:26:47 +0100 |
commit | e6e3823982cb9755b7cb4727fb08171eed5b4332 (patch) | |
tree | e747dbd35b2b8156e0aa2eb8ed63a92d2b3445c3 | |
parent | a93837da703767b6a982ead94494df7c885b46f1 (diff) | |
download | thermoprint-e6e3823982cb9755b7cb4727fb08171eed5b4332.tar thermoprint-e6e3823982cb9755b7cb4727fb08171eed5b4332.tar.gz thermoprint-e6e3823982cb9755b7cb4727fb08171eed5b4332.tar.bz2 thermoprint-e6e3823982cb9755b7cb4727fb08171eed5b4332.tar.xz thermoprint-e6e3823982cb9755b7cb4727fb08171eed5b4332.zip |
Accept trailing newlines
-rw-r--r-- | bbcode/bbcode.cabal | 2 | ||||
-rw-r--r-- | bbcode/bbcode.nix | 2 | ||||
-rw-r--r-- | bbcode/src/Text/BBCode.hs | 4 | ||||
-rw-r--r-- | bbcode/test/Text/BBCodeSpec.hs | 6 |
4 files changed, 10 insertions, 4 deletions
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 @@ | |||
2 | -- documentation, see http://haskell.org/cabal/users-guide/ | 2 | -- documentation, see http://haskell.org/cabal/users-guide/ |
3 | 3 | ||
4 | name: bbcode | 4 | name: bbcode |
5 | version: 3.0.0 | 5 | version: 3.1.0 |
6 | synopsis: A parser for bbcode | 6 | synopsis: A parser for bbcode |
7 | -- description: | 7 | -- description: |
8 | homepage: http://dirty-haskell.org/tags/thermoprint.html | 8 | 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 @@ | |||
3 | }: | 3 | }: |
4 | mkDerivation { | 4 | mkDerivation { |
5 | pname = "bbcode"; | 5 | pname = "bbcode"; |
6 | version = "3.0.0"; | 6 | version = "3.1.0"; |
7 | src = ./.; | 7 | src = ./.; |
8 | libraryHaskellDepends = [ | 8 | libraryHaskellDepends = [ |
9 | attoparsec base case-insensitive containers rosezipper text | 9 | 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) | |||
25 | import Control.Applicative | 25 | import Control.Applicative |
26 | 26 | ||
27 | import Text.BBCode.Lexer (BBToken(..), token) | 27 | import Text.BBCode.Lexer (BBToken(..), token) |
28 | import Data.Attoparsec.Text (parseOnly, endOfInput) | 28 | import Data.Attoparsec.Text (parseOnly, endOfInput, endOfLine) |
29 | 29 | ||
30 | import Data.Tree | 30 | import Data.Tree |
31 | import Data.Tree.Zipper (TreePos, Empty, Full) | 31 | import Data.Tree.Zipper (TreePos, Empty, Full) |
@@ -72,7 +72,7 @@ instance Exception BBCodeError | |||
72 | 72 | ||
73 | bbcode :: Text -> Either BBCodeError DomForest | 73 | bbcode :: Text -> Either BBCodeError DomForest |
74 | -- ^ Parse BBCode | 74 | -- ^ Parse BBCode |
75 | bbcode t = fmap dom $ first LexerError (parseOnly (many token <* endOfInput) t) >>= first TreeError . rose | 75 | bbcode t = fmap dom $ first LexerError (parseOnly (many token <* many endOfLine <* endOfInput) t) >>= first TreeError . rose |
76 | 76 | ||
77 | -- | Errors in input encountered during parsing of lexed token-stream | 77 | -- | Errors in input encountered during parsing of lexed token-stream |
78 | data TreeError = MismatchedTags Text Text -- ^ Closing tags label does not match opening tags | 78 | 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]" | |||
61 | , [[Element "b" [] [Content "foo"]], [Element "b" [] [Content "bar"]]]) | 61 | , [[Element "b" [] [Content "foo"]], [Element "b" [] [Content "bar"]]]) |
62 | , ("[b]foo[/b][b]bar[/b]" | 62 | , ("[b]foo[/b][b]bar[/b]" |
63 | , [[Element "b" [] [Content "foo"], Element "b" [] [Content "bar"]]]) | 63 | , [[Element "b" [] [Content "foo"], Element "b" [] [Content "bar"]]]) |
64 | , ("[b]foo[/b]\n" | ||
65 | , [[Element "b" [] [Content "foo"]]]) | ||
66 | , ("[b]foo[/b] \n" | ||
67 | , [[Element "b" [] [Content "foo"], Content " "]]) | ||
68 | , ("[b]foo[/b] " | ||
69 | , [[Element "b" [] [Content "foo"], Content " "]]) | ||
64 | ] | 70 | ] |
65 | 71 | ||