Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing error #11

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
import System.Process
import System.Exit
import System.IO
import System.Environment

Check warning on line 21 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

The import of ‘System.Environment’ is redundant

Check warning on line 21 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

The import of ‘System.Environment’ is redundant
import qualified Data.Attoparsec.Text as P
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as Char8
import qualified Data.ByteString as BS
import Data.ByteString.Lazy (toStrict)

Check warning on line 26 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

The import of ‘Data.ByteString.Lazy’ is redundant

Check warning on line 26 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

The import of ‘Data.ByteString.Lazy’ is redundant
import Data.Char
import Data.Text (Text)
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import GHC.Generics
import Options.Applicative
import qualified System.IO as IO

Check warning on line 33 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

The qualified import of ‘System.IO’ is redundant

Check warning on line 33 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

The qualified import of ‘System.IO’ is redundant
import qualified Data.Map as Map

import AppKit
Expand Down Expand Up @@ -91,7 +91,7 @@
createMenuItem (MenuItem s []) = newMenuItem s
createMenuItem (MenuItem s cmds) = do
mi <- newMenuItem s
let cmd:args = map Text.unpack cmds

Check warning on line 94 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

Pattern match(es) are non-exhaustive

Check warning on line 94 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

Pattern match(es) are non-exhaustive
let cp = (proc cmd args)
{ std_in = NoStream
, std_out = NoStream
Expand Down Expand Up @@ -164,7 +164,7 @@
initApp
runContT newStatusItem $ \si -> do
let
cmd:args = (Main.command opts)

Check warning on line 167 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

Pattern match(es) are non-exhaustive

Check warning on line 167 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

Pattern match(es) are non-exhaustive
cp = (proc cmd args)
{ close_fds = False
, std_in = NoStream
Expand Down Expand Up @@ -238,7 +238,6 @@
parseInfo = MenuItem <$> (P.takeWhile (/= '\n') <* P.endOfLine) <*> pure []
parseGeneric = do
(name, params) <- parseBodyWithTags
params <- parseAllTags
let pglob = Map.fromListWith (++) $ map (fmap (:[])) params
case lookup "href" params of
Just s -> pure $ MenuItem name ["/usr/bin/open", s]
Expand Down Expand Up @@ -289,7 +288,7 @@
parseTitle :: P.Parser Text
--parseTitle = Text.strip . Text.pack <$> P.manyTill P.anyChar (void (P.string "---\n") <|> P.endOfInput)
parseTitle = do
(t, ts) <- parseBodyWithTags

Check warning on line 291 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

Defined but not used: ‘ts’

Check warning on line 291 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

Defined but not used: ‘ts’
void (P.string "---\n") <|> P.endOfInput
pure t

Expand All @@ -304,13 +303,13 @@

where
go1 :: ByteString -> ByteString
go1 i = case Char8.uncons i of

Check warning on line 306 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

This binding for ‘i’ shadows the existing binding

Check warning on line 306 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

This binding for ‘i’ shadows the existing binding
Just ('[', r) -> go2 r
Just (a, r) -> Char8.cons a $ stripControlSequences r
Nothing -> Char8.empty

go2 :: ByteString -> ByteString
go2 i = case BS.uncons i of

Check warning on line 312 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

This binding for ‘i’ shadows the existing binding

Check warning on line 312 in src/Main.hs

View workflow job for this annotation

GitHub Actions / build

This binding for ‘i’ shadows the existing binding
Just (c, r) -> if c >= 0x40 && c <= 0x7E then stripControlSequences r else go2 r
Nothing -> Char8.empty

Expand Down