aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/src/Thermoprint/Printout/BBCode.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/spec/src/Thermoprint/Printout/BBCode.hs b/spec/src/Thermoprint/Printout/BBCode.hs
index f80f780..cee36b8 100644
--- a/spec/src/Thermoprint/Printout/BBCode.hs
+++ b/spec/src/Thermoprint/Printout/BBCode.hs
@@ -1,6 +1,7 @@
1{-# LANGUAGE OverloadedStrings #-} 1{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE DeriveGeneric #-} 2{-# LANGUAGE DeriveGeneric #-}
3 3
4-- | Use 'Text.BBCode' to parse BBCode
4module Thermoprint.Printout.BBCode 5module Thermoprint.Printout.BBCode
5 ( bbcode 6 ( bbcode
6 , BBCodeError(..) 7 , BBCodeError(..)
@@ -14,6 +15,9 @@ import qualified Data.Text as T (unpack)
14import Data.Map (Map) 15import Data.Map (Map)
15import qualified Data.Map as Map (lookup) 16import qualified Data.Map as Map (lookup)
16 17
18import Data.Sequence (Seq)
19import qualified Data.Sequence as Seq ()
20
17import Data.CaseInsensitive (CI) 21import Data.CaseInsensitive (CI)
18import qualified Data.CaseInsensitive as CI 22import qualified Data.CaseInsensitive as CI
19 23
@@ -41,13 +45,14 @@ data BBCodeError = LexerError String -- ^ Error while parsing input to stream of
41 45
42instance Exception BBCodeError 46instance Exception BBCodeError
43 47
44data SemanticError = BlockTagInLineContext Text 48-- ^ An error ocurred while parsing the DOM-Forest (`['DomTree']`)
45 | UnmappedTag Text 49data SemanticError = UnmappedTag Text -- ^ An `Element` does not map to any structure in the context it occurred in
46 deriving (Show, Eq, Generic, Typeable) 50 deriving (Show, Eq, Generic, Typeable)
47 51
48instance Exception SemanticError 52instance Exception SemanticError
49 53
50bbcode :: Text -> Either BBCodeError Printout 54bbcode :: Text -> Either BBCodeError Printout
55-- ^ Parse BBCode
51bbcode = join . fmap (first SemanticError) . bimap morph' morph . Raw.bbcode 56bbcode = join . fmap (first SemanticError) . bimap morph' morph . Raw.bbcode
52 57
53morph' :: Raw.BBCodeError -> BBCodeError 58morph' :: Raw.BBCodeError -> BBCodeError