From 8670cb04f09e22133c7b26dd01b9426f021062a3 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Mon, 6 Apr 2020 10:55:56 +1200 Subject: [PATCH] Remove dead imports. --- src/Input.hs | 37 +++++++++++++------------------------ src/Render.hs | 11 ----------- src/StyleTree.hs | 2 -- 3 files changed, 13 insertions(+), 37 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index c7749e5..4e8b26b 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -11,22 +11,11 @@ import Network.URI import Network.URI.Fetch import qualified Data.Map as M -import Control.Concurrent.Async import System.IO -import System.Environment -import System.Directory import System.IO.Temp -import Data.List import Data.Default.Class -import Data.Maybe (fromMaybe) -import System.FilePath - -import qualified Data.CSS.Syntax.StyleSheet as CSS -import Data.CSS.Preprocessor.Conditions -import qualified Data.CSS.Syntax.Tokens as CSSTok -import qualified Data.HTML2CSS as H2C -import Network.URI.Charset +-- FIXME segfaults when exposed to C. --fetchURLs session refererDoc refererURL srcs = forConcurrently srcs $ \(mime, url) -> do -- let u = relativeTo url refererURL -- let charsets' = map Txt.unpack charsets @@ -38,18 +27,18 @@ import Network.URI.Charset -- _ -> parseDocument session resp >>= \doc -> return (doc, H2C.html2css doc refererURL) -- return (u, a, b) -applyCSScharset (charset:charsets) (Right bytes) - | cssCharset (CSSTok.tokenize text) == Txt.pack charset = text - | otherwise = applyCSScharset charsets $ Right bytes - where - text = convertCharset charset $ B.toStrict bytes -applyCSScharset _ (Right bytes) = convertCharset "utf-8" $ B.toStrict bytes -applyCSScharset _ (Left text) = text -cssCharset toks | (CSSTok.AtKeyword "charset":toks') <- skipCSSspace toks, - (CSSTok.String charset:_) <- skipCSSspace toks' = charset - | otherwise = "" -skipCSSspace (CSSTok.Whitespace:toks) = skipCSSspace toks -skipCSSspace toks = toks +--applyCSScharset (charset:charsets) (Right bytes) +-- | cssCharset (CSSTok.tokenize text) == Txt.pack charset = text +-- | otherwise = applyCSScharset charsets $ Right bytes +-- where +-- text = convertCharset charset $ B.toStrict bytes +--applyCSScharset _ (Right bytes) = convertCharset "utf-8" $ B.toStrict bytes +--applyCSScharset _ (Left text) = text +--cssCharset toks | (CSSTok.AtKeyword "charset":toks') <- skipCSSspace toks, +-- (CSSTok.String charset:_) <- skipCSSspace toks' = charset +-- | otherwise = "" +--skipCSSspace (CSSTok.Whitespace:toks) = skipCSSspace toks +--skipCSSspace toks = toks fetchDocument http mime uri = fetchURL http mime uri >>= parseDocument http parseDocument _ ("text/html", Left text) = return $ HTML.parseLT $ fromStrict text diff --git a/src/Render.hs b/src/Render.hs index 76ea39e..f70aa5f 100644 --- a/src/Render.hs +++ b/src/Render.hs @@ -1,21 +1,12 @@ {-# LANGUAGE OverloadedStrings #-} module Render(retreiveStyles, renderDoc) where -import qualified Data.ByteString.Lazy.Char8 as C8 import qualified Data.ByteString.Lazy as B - import qualified Text.XML as XML import Data.Text as Txt (pack, unpack, Text(..), intercalate) import qualified Data.Map as M import System.Directory as Dir -import Control.Monad -import System.IO (stdout, hPutStrLn) - --- To handle text encoding errors, whilst trying them out -import System.IO.Unsafe (unsafePerformIO) -import Control.Exception (catch, evaluate) -import Data.Text.Encoding.Error (UnicodeException) --- External Rhapsode subcomponents import qualified Data.CSS.Syntax.StyleSheet as CSS @@ -30,8 +21,6 @@ import Network.URI.Charset import DefaultCSS import StyleTree import SSML -import Input -import Links renderDoc style html = renderElLBS $ styleToSSML $ applyCounters $ stylize style html diff --git a/src/StyleTree.hs b/src/StyleTree.hs index 25b7ca4..c08b10d 100644 --- a/src/StyleTree.hs +++ b/src/StyleTree.hs @@ -5,8 +5,6 @@ module StyleTree( ) where import Data.CSS.Syntax.Tokens -import Data.Map -import qualified Data.HTML2CSS as H2C import qualified Data.CSS.Style as Style import Data.Text import Data.Scientific (toRealFloat) -- 2.30.2