@@ 402,17 402,21 @@ setContent value self = self {
collapseWS :: StyleTree (TextStyle p) -> StyleTree (TextStyle p)
collapseWS = treeOrder collapseWS0 True
collapseWS0 :: Bool -> Bool -> Path -> TextStyle p -> (Bool, TextStyle p)
-collapseWS0 _ _ _ node@(TextStyle {whiteSpaceCollapse = False, newlineCollapse = False}) = (False, node)
+collapseWS0 _ _ _ node@(TextStyle {
+ whiteSpaceCollapse = False, newlineCollapse = False }) = (False, node)
collapseWS0 _ inSpace _ node@(TextStyle {
whiteSpaceCollapse = wsCollapse,
newlineCollapse = nlCollapse
}) = (trailingSpace, setContent content' node)
- where (trailingSpace, content') = collapseWSToks inSpace wsCollapse nlCollapse $ content node
+ where (trailingSpace, content') =
+ collapseWSToks inSpace wsCollapse nlCollapse $ content node
collapseWSToks :: Bool -> Bool -> Bool -> [Token] -> (Bool, [Token])
collapseWSToks stripStart wsCollapse nlCollapse (String txt:toks) =
- let (trailingSpace, str') = collapseWSStr stripStart wsCollapse nlCollapse $ Txt.unpack txt
- (trailingSpace', toks') = collapseWSToks trailingSpace wsCollapse nlCollapse toks
+ let (trailingSpace, str') =
+ collapseWSStr stripStart wsCollapse nlCollapse $ Txt.unpack txt
+ (trailingSpace', toks') =
+ collapseWSToks trailingSpace wsCollapse nlCollapse toks
in (trailingSpace', String (Txt.pack str'):toks')
collapseWSToks _ wsCollapse nlCollapse (tok:toks) =
let (trailingSpace, toks') = collapseWSToks False wsCollapse nlCollapse toks
@@ 420,9 424,14 @@ collapseWSToks _ wsCollapse nlCollapse (tok:toks) =
collapseWSToks trailingWS _ _ [] = (trailingWS, [])
collapseWSStr, collapseWSStr' :: Bool -> Bool -> Bool -> String -> (Bool, String)
-collapseWSStr _ wsCollapse False str@('\n':_) = collapseWSStr' True wsCollapse True str
-collapseWSStr True True nlCollapse (ch:str) | isSpace ch = collapseWSStr True True nlCollapse str
-collapseWSStr False True nlCollapse str@(ch:_) | isSpace ch = collapseWSStr' True True nlCollapse str
-collapseWSStr _ wsCollapse nlCollapse str = collapseWSStr' False wsCollapse nlCollapse str
-collapseWSStr' a b c (d:ds) = let (trailing, ds') = collapseWSStr a b c ds in (trailing, d:ds')
+collapseWSStr _ wsCollapse False str@('\n':_) =
+ collapseWSStr' True wsCollapse False str
+collapseWSStr True True nlCollapse (ch:str) | isSpace ch =
+ collapseWSStr True True nlCollapse str
+collapseWSStr False True nlCollapse str@(ch:_) | isSpace ch =
+ collapseWSStr' True True nlCollapse str
+collapseWSStr _ wsCollapse nlCollapse str =
+ collapseWSStr' False wsCollapse nlCollapse str
+collapseWSStr' a b c (d:ds) =
+ let (trailing, ds') = collapseWSStr a b c ds in (trailing, d:ds')
collapseWSStr' a _ _ [] = (a, [])