From 07759433a7e075e99267e2ea04f232c99118c9fd Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 12 Jan 2016 06:26:48 +0000 Subject: differentiating plain strings and tags (hack) --- bbcode/src/Text/BBCode.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bbcode/src/Text') diff --git a/bbcode/src/Text/BBCode.hs b/bbcode/src/Text/BBCode.hs index 4b2ee6e..1e9960a 100644 --- a/bbcode/src/Text/BBCode.hs +++ b/bbcode/src/Text/BBCode.hs @@ -38,7 +38,7 @@ data TreeError = MismatchedTags Text Text -- ^ Closing tags does not match openi instance Exception TreeError -- | The label of our rose-tree nodes carries the tag name and a map of attributes -type BBLabel = (Text, Map Text (Maybe Text)) +type BBLabel = (Text, Maybe (Map Text (Maybe Text))) matches :: Text -> Text -> Bool -- ^ @`matches` "open" "close"@ should be 'True' iff @[/close]@ is a valid closing tag for @[open]@ @@ -54,8 +54,8 @@ rose = fmap Z.toForest . flip rose' (Z.fromForest []) rose' [] = return rose' (x:xs) = (>>= rose' xs) . rose'' x - rose'' (BBStr t) = return . Z.nextSpace . Z.insert (Node (t, Map.empty) []) - rose'' (BBOpen t attrs) = return . Z.children . Z.insert (Node (t, Map.fromList attrs) []) + rose'' (BBStr t) = return . Z.nextSpace . Z.insert (Node (t, Nothing) []) + rose'' (BBOpen t attrs) = return . Z.children . Z.insert (Node (t, Just $ Map.fromList attrs) []) rose'' (BBClose t) = close t -- for more pointless close :: Text -> TreePos Empty BBLabel -> Either TreeError (TreePos Empty BBLabel) -- cgit v1.2.3