Skip to content

Commit

Permalink
Fix word boundary detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm committed Jul 29, 2020
1 parent 2aaa6b0 commit 7f65eb7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion skylighting-core/src/Regex/KDE.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}
module Regex.KDE
(Regex(..), compileRegex, matchRegex, testRegex)
(Regex(..), compileRegex, matchRegex, testRegex, isWordChar)
where

import Regex.KDE.Regex
Expand Down
1 change: 1 addition & 0 deletions skylighting-core/src/Skylighting/Regex.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Skylighting.Regex (
, compileRegex
, matchRegex
, testRegex
, isWordChar
) where

import Data.Aeson
Expand Down
8 changes: 1 addition & 7 deletions skylighting-core/src/Skylighting/Tokenizer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,8 @@ wordBoundary inp = do
c <- gets prevChar
guard $ isWordBoundary c d

-- TODO is this right?
isWordBoundary :: Char -> Char -> Bool
isWordBoundary c d =
(isAlphaNum c && not (isAlphaNum d))
|| (isAlphaNum d && not (isAlphaNum c))
|| (isSpace d && not (isSpace c))
|| (isSpace c && not (isSpace d))

isWordBoundary c d = isWordChar c /= isWordChar d

decodeBS :: ByteString -> TokenizerM Text
decodeBS bs = case decodeUtf8' bs of
Expand Down

0 comments on commit 7f65eb7

Please sign in to comment.