@@ -190,22 +190,22 @@ item_test = testing "Input.Item.Target JSON (encode . decode = id) " $ do
190190 (Left e ) -> False
191191 (Right t') -> t == t'
192192
193- highlightItem :: Monoid m => (String -> m ) -> (String -> m ) -> (String -> m ) -> [Query ] -> String -> m
194- highlightItem plain dull bold qs x
193+ highlightItem :: Monoid m => (String -> m ) -> (String -> m ) -> (String -> m ) -> ( String -> m ) -> [Query ] -> String -> m
194+ highlightItem plain safe dull bold qs x
195195 | Just (pre,x) <- stripInfix " <s0>" x, Just (name,post) <- stripInfix " </s0>" x
196- = plain pre <> highlight (unescapeHTML name) <> plain post
196+ = safe pre <> highlight (unescapeHTML name) <> safe post
197197 | otherwise = plain x
198198 where
199- highlight = mconcatMap (\ xs@ ((b,_): _) -> let s = map snd xs in if b then bold s else dull s) .
200- groupOn fst . ( \ x -> zip (mapIsInQueries x) x)
199+ highlight x = mconcatMap (\ xs@ ((b,_): _) -> let s = map snd xs in if b then bold s else dull s) $
200+ groupOn fst $ zip (findQueries x) x
201201 where
202202 -- generates a bool mask, which is only true for charachters that compose given queries
203203 -- e.g. [ "query" "ya" ] -> [ "AqUeRyAA" ] -> 01111110
204- mapIsInQueries :: String -> [Bool ]
205- mapIsInQueries (x: xs) | m > 0 = replicate m True ++ (mapIsInQueries $ drop (m - 1 ) xs)
204+ findQueries :: String -> [Bool ]
205+ findQueries (x: xs) | m > 0 = replicate m True ++ drop (m - 1 ) (findQueries xs)
206206 where m = maximum $ 0 : [length y | QueryName y <- qs, lower y `isPrefixOf` lower (x: xs)]
207- mapIsInQueries (x: xs) = False : mapIsInQueries xs
208- mapIsInQueries [] = []
207+ findQueries (x: xs) = False : findQueries xs
208+ findQueries [] = []
209209
210210---------------------------------------------------------------------
211211-- HSE CONVERSION
0 commit comments