aboutsummaryrefslogtreecommitdiff
path: root/bbcode/src/Text/BBCode.hs
diff options
context:
space:
mode:
Diffstat (limited to 'bbcode/src/Text/BBCode.hs')
-rw-r--r--bbcode/src/Text/BBCode.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/bbcode/src/Text/BBCode.hs b/bbcode/src/Text/BBCode.hs
index 8f04f19..ac56974 100644
--- a/bbcode/src/Text/BBCode.hs
+++ b/bbcode/src/Text/BBCode.hs
@@ -50,14 +50,16 @@ type DomForest = [[DomTree]]
50dom :: Forest BBLabel -> DomForest 50dom :: Forest BBLabel -> DomForest
51-- ^ Parse semantically constrained rose tree to syntactically constrained version 51-- ^ Parse semantically constrained rose tree to syntactically constrained version
52-- 52--
53-- Silently drops children of semantically terminal nodes ('BBPlain') and paragraphs anywhere but at top level 53-- Silently drops children of semantically terminal nodes ('BBPlain')
54dom = map fromPar 54--
55-- We already ensured that paragraphs occur nowhere but at toplevel
56dom = map (\(Node BBPar ts) -> map dom' ts) . ensureTopLevelPar
55 where 57 where
56 fromPar (Node BBPar ts) = concatMap dom' ts 58 ensureTopLevelPar xs@((Node BBPar _):_) = xs
57 fromPar x = dom' x 59 ensureTopLevelPar xs = pure $ Node BBPar xs
58 dom' (Node (BBPlain t) _) = pure $ Content t 60
59 dom' (Node (BBTag t attrs) ts) = pure . Element (CI.mk t) (Map.mapKeys CI.mk attrs) $ concatMap dom' ts 61 dom' (Node (BBPlain t) _) = Content t
60 dom' (Node BBPar _) = [] 62 dom' (Node (BBTag t attrs) ts) = Element (CI.mk t) (Map.mapKeys CI.mk attrs) $ map dom' ts
61 63
62-- | Errors encountered during parsing 64-- | Errors encountered during parsing
63data BBCodeError = LexerError String -- ^ Error while parsing input to stream of tokens 65data BBCodeError = LexerError String -- ^ Error while parsing input to stream of tokens