aboutsummaryrefslogtreecommitdiff
path: root/bbcode
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2015-10-18 00:13:32 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2015-10-18 00:13:32 +0200
commitf9edf473fe3cc6c2dc0bf5d2829c2287baa1a0a6 (patch)
tree8711caffd49f24ee8136523e0aefc76e37d8666a /bbcode
parent6db9326c348f54cd25f399ad1e472b20cb7771c0 (diff)
downloadthermoprint-f9edf473fe3cc6c2dc0bf5d2829c2287baa1a0a6.tar
thermoprint-f9edf473fe3cc6c2dc0bf5d2829c2287baa1a0a6.tar.gz
thermoprint-f9edf473fe3cc6c2dc0bf5d2829c2287baa1a0a6.tar.bz2
thermoprint-f9edf473fe3cc6c2dc0bf5d2829c2287baa1a0a6.tar.xz
thermoprint-f9edf473fe3cc6c2dc0bf5d2829c2287baa1a0a6.zip
Revert "Added massaging to make sure blocks are not followed by extraneous whitespace"
This reverts commit 6db9326c348f54cd25f399ad1e472b20cb7771c0.
Diffstat (limited to 'bbcode')
-rw-r--r--bbcode/src/BBCode.hs15
1 files changed, 1 insertions, 14 deletions
diff --git a/bbcode/src/BBCode.hs b/bbcode/src/BBCode.hs
index 118aed7..3071db6 100644
--- a/bbcode/src/BBCode.hs
+++ b/bbcode/src/BBCode.hs
@@ -55,20 +55,7 @@ make' (Cooked c) = c
55make' (Raw _) = error "Cannot transform block containing raw data to bbcode" 55make' (Raw _) = error "Cannot transform block containing raw data to bbcode"
56 56
57parse :: String -> Either String (Block String) 57parse :: String -> Either String (Block String)
58parse input = (remerge . massage . blockify <$> (tokenize input >>= treeify)) >>= semantics 58parse input = (remerge . blockify <$> (tokenize input >>= treeify)) >>= semantics
59
60massage :: [Decorated String] -> [Decorated String]
61massage [] = []
62massage (x@(Decorated _ tags) : x'@(Decorated wSpace []) : xs)
63 | any $ map isSpace wSpace
64 , any $ map isBlock tags = (x:Decorated (massage' wSpace) []:xs)
65 | otherwise = x : massage (x':xs)
66 where
67 massage' [] = []
68 massage' l@(x:xs)
69 | isSpace x = massage' xs
70 | otherwise = l
71massage (x:xs) = x : massage xs
72 59
73blockify :: ContentForest -> [Decorated String] 60blockify :: ContentForest -> [Decorated String]
74blockify = map sortDeco . concat . map (blockify' []) 61blockify = map sortDeco . concat . map (blockify' [])