diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-12 06:26:48 +0000 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-12 06:26:48 +0000 |
commit | 07759433a7e075e99267e2ea04f232c99118c9fd (patch) | |
tree | f994df88fb0dfb27cae4c48964f0c962f288eba9 /bbcode | |
parent | 69fc73e75a7f7fe388023d16990e9e701b7384e0 (diff) | |
download | thermoprint-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.hs | 6 |
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 | |||
38 | instance Exception TreeError | 38 | instance 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 |
41 | type BBLabel = (Text, Map Text (Maybe Text)) | 41 | type BBLabel = (Text, Maybe (Map Text (Maybe Text))) |
42 | 42 | ||
43 | matches :: Text -> Text -> Bool | 43 | matches :: 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) |