@@ -11,8 +11,8 @@ import Data.Foldable (any, all)
1111import Data.List ((:))
1212import Data.List as L
1313import Data.Maybe as M
14- import Data.Monoid ( mempty )
15- import Data.String as S
14+ import Data.String ( Pattern (..), Replacement (..), drop , length , replace , split , take , trim ) as S
15+ import Data.String.CodeUnits ( countPrefix , dropWhile , singleton ) as S
1616import Data.String.Regex as RGX
1717import Data.String.Regex.Unsafe as URX
1818import Data.String.Regex.Flags as RXF
@@ -59,7 +59,7 @@ allChars p = all p <<< S.split (S.Pattern "")
5959
6060removeNonIndentingSpaces ∷ String → String
6161removeNonIndentingSpaces s
62- | S .count (isSpace <<< S .singleton) s < 4 = S .dropWhile (isSpace <<< S .singleton) s
62+ | S .countPrefix (isSpace <<< S .singleton) s < 4 = S .dropWhile (isSpace <<< S .singleton) s
6363 | otherwise = s
6464
6565isRuleChar ∷ String → Boolean
@@ -77,15 +77,15 @@ isRule s =
7777isATXHeader ∷ String → Boolean
7878isATXHeader s =
7979 let
80- level = S .count (\c → S .singleton c == " #" ) s
80+ level = S .countPrefix (\c → S .singleton c == " #" ) s
8181 rest = S .drop level s
8282 in
8383 level >= 1 && level <= 6 && S .take 1 rest == " "
8484
8585splitATXHeader ∷ String → { level ∷ Int , contents ∷ String }
8686splitATXHeader s =
8787 let
88- level = S .count (\c → S .singleton c == " #" ) s
88+ level = S .countPrefix (\c → S .singleton c == " #" ) s
8989 contents = S .drop (level + 1 ) s
9090 in
9191 { level: level
@@ -120,7 +120,7 @@ splitBlockquote ss =
120120 blockquoteContents s = S .drop (if S .take 2 s == " > " then 2 else 1 ) s
121121
122122countLeadingSpaces ∷ String → Int
123- countLeadingSpaces = S .count (isSpace <<< S .singleton)
123+ countLeadingSpaces = S .countPrefix (isSpace <<< S .singleton)
124124
125125isBulleted ∷ String → Boolean
126126isBulleted s =
@@ -139,7 +139,7 @@ isBulleted s =
139139isOrderedListMarker ∷ String → Boolean
140140isOrderedListMarker s =
141141 let
142- n = S .count (isDigit <<< S .singleton) s
142+ n = S .countPrefix (isDigit <<< S .singleton) s
143143 next = S .take 1 (S .drop n s)
144144 ls = countLeadingSpaces (S .drop (n + 1 ) s)
145145 in
@@ -149,14 +149,14 @@ listItemType ∷ String → SD.ListType
149149listItemType s
150150 | isBulleted s = SD.Bullet (S .take 1 s)
151151 | otherwise =
152- let n = S .count (isDigit <<< S .singleton) s
152+ let n = S .countPrefix (isDigit <<< S .singleton) s
153153 in SD.Ordered (S .take 1 (S .drop n s))
154154
155155listItemIndent ∷ String → Int
156156listItemIndent s
157157 | isBulleted s = 1 + min 4 (countLeadingSpaces (S .drop 1 s))
158158 | otherwise =
159- let n = S .count (isDigit <<< S .singleton) s
159+ let n = S .countPrefix (isDigit <<< S .singleton) s
160160 in n + 1 + min 4 (countLeadingSpaces (S .drop (n + 1 ) s))
161161
162162isListItemLine ∷ String → Boolean
@@ -210,7 +210,7 @@ splitIndentedChunks ss =
210210isCodeFence ∷ String → Boolean
211211isCodeFence s = isSimpleFence s || (isEvaluatedCode s && isSimpleFence (S .drop 1 s))
212212 where
213- isSimpleFence s' = S .count (isFenceChar <<< S .singleton) s' >= 3
213+ isSimpleFence s' = S .countPrefix (isFenceChar <<< S .singleton) s' >= 3
214214
215215isEvaluatedCode ∷ String → Boolean
216216isEvaluatedCode s = S .take 1 s == " !"
@@ -243,7 +243,7 @@ splitCodeFence indent fence ss =
243243 }
244244 where
245245 isClosingFence ∷ String → Boolean
246- isClosingFence s = S .count (\c → S .singleton c == fence) (removeNonIndentingSpaces s) >= 3
246+ isClosingFence s = S .countPrefix (\c → S .singleton c == fence) (removeNonIndentingSpaces s) >= 3
247247
248248 removeIndentTo ∷ String → String
249249 removeIndentTo s = S .drop (min indent (countLeadingSpaces s)) s
0 commit comments