Permalink
Browse files

Merge pull request #5 from Palmik/master

Using Stream instance for Text from Text.Parsec.Text.
  • Loading branch information...
2 parents 54031d9 + 42bb760 commit 2d8704724dc643707865bf2f6c00f87b21c692cf @mightybyte mightybyte committed Feb 6, 2012
Showing with 16 additions and 17 deletions.
  1. +14 −15 src/Text/XmlHtml/TextParser.hs
  2. +2 −2 xmlhtml.cabal
@@ -2,7 +2,19 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
-module Text.XmlHtml.TextParser where
+module Text.XmlHtml.TextParser
+( guessEncoding
+, parse
+, isValidChar
+, parseText
+, takeWhile0
+, takeWhile1
+, text
+, scanText
+, ScanState(..)
+
+, module Text.Parsec.Text
+) where
import Control.Applicative
import Data.Char
@@ -12,13 +24,12 @@ import Text.XmlHtml.Common
import Data.Text (Text)
import qualified Data.Text as T
-import Text.Parsec (Parsec)
import qualified Text.Parsec as P
+import Text.Parsec.Text
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
-
------------------------------------------------------------------------------
-- | Get an initial guess at document encoding from the byte order mark. If
-- the mark doesn't exist, guess UTF-8. Otherwise, guess according to the
@@ -30,18 +41,6 @@ guessEncoding b
| B.take 2 b == B.pack [ 0xFF, 0xFE ] = (UTF16LE, B.drop 2 b)
| otherwise = (UTF8, b)
-
-------------------------------------------------------------------------------
--- | Specialized type for the parsers we use here.
-type Parser = Parsec Text ()
-
-
-------------------------------------------------------------------------------
--- An (orphaned) instance for parsing Text with Parsec.
-instance (Monad m) => P.Stream T.Text m Char where
- uncons = return . T.uncons
-
-
------------------------------------------------------------------------------
parse :: (Encoding -> Parser a) -> String -> ByteString -> Either String a
parse p src b = let (e, b') = guessEncoding b
View
@@ -1,5 +1,5 @@
Name: xmlhtml
-Version: 0.1.6.1
+Version: 0.1.6.2
Synopsis: XML parser and renderer with HTML 5 quirks mode
Description: Contains renderers and parsers for both XML and HTML 5
document fragments, which share data structures wo that
@@ -823,7 +823,7 @@ Library
blaze-html >= 0.3.2 && < 0.5,
bytestring >= 0.9 && < 0.10,
containers >= 0.3 && < 0.5,
- parsec >= 3.0 && < 3.2,
+ parsec >= 3.1 && < 3.2,
text >= 0.11 && < 0.12,
unordered-containers >= 0.1.4 && < 0.2

0 comments on commit 2d87047

Please sign in to comment.