lib: Use text library functions for stripping.
This commit is contained in:
		
							parent
							
								
									ed99aea7d5
								
							
						
					
					
						commit
						dc076b0d5b
					
				| @ -361,7 +361,7 @@ commentAddTag c (t,v) | ||||
|   | T.null c' = tag | ||||
|   | otherwise = c' `commentJoin` tag | ||||
|   where | ||||
|     c'  = textchomp c | ||||
|     c'  = T.stripEnd c | ||||
|     tag = t <> ": " <> v | ||||
| 
 | ||||
| -- | Add a tag on its own line to a comment, preserving any prior content. | ||||
|  | ||||
| @ -121,7 +121,7 @@ transactionNote = snd . payeeAndNoteFromDescription . tdescription | ||||
| payeeAndNoteFromDescription :: Text -> (Text,Text) | ||||
| payeeAndNoteFromDescription t | ||||
|   | T.null n = (t, t) | ||||
|   | otherwise = (textstrip p, textstrip $ T.drop 1 n) | ||||
|   | otherwise = (T.strip p, T.strip $ T.drop 1 n) | ||||
|   where | ||||
|     (p, n) = T.span (/= '|') t | ||||
| 
 | ||||
|  | ||||
| @ -27,10 +27,6 @@ module Hledger.Utils.Text | ||||
|  -- isSingleQuoted, | ||||
|  -- isDoubleQuoted, | ||||
|  -- -- * single-line layout | ||||
|   textstrip, | ||||
|   textlstrip, | ||||
|   textrstrip, | ||||
|   textchomp, | ||||
|  -- elideLeft, | ||||
|   textElideRight, | ||||
|  -- formatString, | ||||
| @ -78,22 +74,6 @@ import Hledger.Utils.Test | ||||
| -- lowercase = map toLower | ||||
| -- uppercase = map toUpper | ||||
| 
 | ||||
| -- | Remove leading and trailing whitespace. | ||||
| textstrip :: Text -> Text | ||||
| textstrip = textlstrip . textrstrip | ||||
| 
 | ||||
| -- | Remove leading whitespace. | ||||
| textlstrip :: Text -> Text | ||||
| textlstrip = T.dropWhile (`elem` (" \t" :: String)) :: Text -> Text -- XXX isSpace ? | ||||
| 
 | ||||
| -- | Remove trailing whitespace. | ||||
| textrstrip = T.reverse . textlstrip . T.reverse | ||||
| textrstrip :: Text -> Text | ||||
| 
 | ||||
| -- | Remove trailing newlines/carriage returns (and other whitespace). | ||||
| textchomp :: Text -> Text | ||||
| textchomp = T.stripEnd | ||||
| 
 | ||||
| -- stripbrackets :: String -> String | ||||
| -- stripbrackets = dropWhile (`elem` "([") . reverse . dropWhile (`elem` "])") . reverse :: String -> String | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user