aboutsummaryrefslogtreecommitdiff
path: root/bbcode
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-01-12 06:26:48 +0000
committerGregor Kleen <gkleen@yggdrasil.li>2016-01-12 06:26:48 +0000
commit07759433a7e075e99267e2ea04f232c99118c9fd (patch)
treef994df88fb0dfb27cae4c48964f0c962f288eba9 /bbcode
parent69fc73e75a7f7fe388023d16990e9e701b7384e0 (diff)
downloadthermoprint-07759433a7e075e99267e2ea04f232c99118c9fd.tar
thermoprint-07759433a7e075e99267e2ea04f232c99118c9fd.tar.gz
thermoprint-07759433a7e075e99267e2ea04f232c99118c9fd.tar.bz2
thermoprint-07759433a7e075e99267e2ea04f232c99118c9fd.tar.xz
thermoprint-07759433a7e075e99267e2ea04f232c99118c9fd.zip
differentiating plain strings and tags (hack)
Diffstat (limited to 'bbcode')
-rw-r--r--bbcode/src/Text/BBCode.hs6
1 files changed, 3 insertions, 3 deletions
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
38instance Exception TreeError 38instance Exception TreeError
39 39
40-- | The label of our rose-tree nodes carries the tag name and a map of attributes 40-- | The label of our rose-tree nodes carries the tag name and a map of attributes
41type BBLabel = (Text, Map Text (Maybe Text)) 41type BBLabel = (Text, Maybe (Map Text (Maybe Text)))
42 42
43matches :: Text -> Text -> Bool 43matches :: Text -> Text -> Bool
44-- ^ @`matches` "open" "close"@ should be 'True' iff @[/close]@ is a valid closing tag for @[open]@ 44-- ^ @`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 [])
54 rose' [] = return 54 rose' [] = return
55 rose' (x:xs) = (>>= rose' xs) . rose'' x 55 rose' (x:xs) = (>>= rose' xs) . rose'' x
56 56
57 rose'' (BBStr t) = return . Z.nextSpace . Z.insert (Node (t, Map.empty) []) 57 rose'' (BBStr t) = return . Z.nextSpace . Z.insert (Node (t, Nothing) [])
58 rose'' (BBOpen t attrs) = return . Z.children . Z.insert (Node (t, Map.fromList attrs) []) 58 rose'' (BBOpen t attrs) = return . Z.children . Z.insert (Node (t, Just $ Map.fromList attrs) [])
59 rose'' (BBClose t) = close t -- for more pointless 59 rose'' (BBClose t) = close t -- for more pointless
60 60
61 close :: Text -> TreePos Empty BBLabel -> Either TreeError (TreePos Empty BBLabel) 61 close :: Text -> TreePos Empty BBLabel -> Either TreeError (TreePos Empty BBLabel)