diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-15 04:24:57 +0000 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-15 04:24:57 +0000 |
| commit | 539b69b3e3b0c4ffee2323a8fe6239ebda4af48c (patch) | |
| tree | 60fd3da78d1ffef0db0d8fdd7a588eceaea4adfa | |
| parent | f7182fe913d3c31d9be2fd8e929072321620211d (diff) | |
| download | thermoprint-539b69b3e3b0c4ffee2323a8fe6239ebda4af48c.tar thermoprint-539b69b3e3b0c4ffee2323a8fe6239ebda4af48c.tar.gz thermoprint-539b69b3e3b0c4ffee2323a8fe6239ebda4af48c.tar.bz2 thermoprint-539b69b3e3b0c4ffee2323a8fe6239ebda4af48c.tar.xz thermoprint-539b69b3e3b0c4ffee2323a8fe6239ebda4af48c.zip | |
predictive documentation
| -rw-r--r-- | spec/src/Thermoprint/Printout/BBCode.hs | 9 |
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 | ||
| 4 | module Thermoprint.Printout.BBCode | 5 | module Thermoprint.Printout.BBCode |
| 5 | ( bbcode | 6 | ( bbcode |
| 6 | , BBCodeError(..) | 7 | , BBCodeError(..) |
| @@ -14,6 +15,9 @@ import qualified Data.Text as T (unpack) | |||
| 14 | import Data.Map (Map) | 15 | import Data.Map (Map) |
| 15 | import qualified Data.Map as Map (lookup) | 16 | import qualified Data.Map as Map (lookup) |
| 16 | 17 | ||
| 18 | import Data.Sequence (Seq) | ||
| 19 | import qualified Data.Sequence as Seq () | ||
| 20 | |||
| 17 | import Data.CaseInsensitive (CI) | 21 | import Data.CaseInsensitive (CI) |
| 18 | import qualified Data.CaseInsensitive as CI | 22 | import qualified Data.CaseInsensitive as CI |
| 19 | 23 | ||
| @@ -41,13 +45,14 @@ data BBCodeError = LexerError String -- ^ Error while parsing input to stream of | |||
| 41 | 45 | ||
| 42 | instance Exception BBCodeError | 46 | instance Exception BBCodeError |
| 43 | 47 | ||
| 44 | data SemanticError = BlockTagInLineContext Text | 48 | -- ^ An error ocurred while parsing the DOM-Forest (`['DomTree']`) |
| 45 | | UnmappedTag Text | 49 | data 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 | ||
| 48 | instance Exception SemanticError | 52 | instance Exception SemanticError |
| 49 | 53 | ||
| 50 | bbcode :: Text -> Either BBCodeError Printout | 54 | bbcode :: Text -> Either BBCodeError Printout |
| 55 | -- ^ Parse BBCode | ||
| 51 | bbcode = join . fmap (first SemanticError) . bimap morph' morph . Raw.bbcode | 56 | bbcode = join . fmap (first SemanticError) . bimap morph' morph . Raw.bbcode |
| 52 | 57 | ||
| 53 | morph' :: Raw.BBCodeError -> BBCodeError | 58 | morph' :: Raw.BBCodeError -> BBCodeError |
