hxt 8.4.0 → 8.4.1
raw patch · 6 files changed
+49/−23 lines, 6 filesdep ~tagsoup
Dependency ranges changed: tagsoup
Files
- examples/arrows/AGentleIntroductionToHXT/PicklerExample/Baseball.hs +1/−2
- examples/arrows/AGentleIntroductionToHXT/SimpleExamples.hs +0/−3
- examples/arrows/HelloWorld/Mini.hs +2/−3
- hxt.cabal +2/−2
- src/Text/XML/HXT/Parser/TagSoup.hs +43/−12
- src/Text/XML/HXT/Version.hs +1/−1
examples/arrows/AGentleIntroductionToHXT/PicklerExample/Baseball.hs view
@@ -10,11 +10,10 @@ where import Data.Map (Map, fromList, toList)-import qualified Data.Map as M import Text.XML.HXT.Arrow --- Example data drawn from:+-- Example data taken from: -- http://www.ibiblio.org/xml/books/bible/examples/05/5-1.xml -- ------------------------------------------------------------
examples/arrows/AGentleIntroductionToHXT/SimpleExamples.hs view
@@ -12,9 +12,6 @@ import Data.List -- auxiliary functions import Data.Maybe --- import Data.Tree.Class (Tree)--import System.IO import System.Environment import System.Console.GetOpt() import System.Exit
examples/arrows/HelloWorld/Mini.hs view
@@ -5,11 +5,10 @@ main :: IO() main- = do- runX ( readDocument [ (a_validate, v_0) ] "hello.xml"+ = runX ( readDocument [ (a_validate, v_0) ] "hello.xml" >>> writeDocument [ ] "bye.xml" )- return ()+ >> return ()
hxt.cabal view
@@ -1,6 +1,6 @@ -- arch-tag: Haskell XML Toolbox main description file name: hxt-version: 8.4.0+version: 8.4.1 license: OtherLicense license-file: LICENCE maintainer: Uwe Schmidt <uwe@fh-wedel.de>@@ -192,5 +192,5 @@ network >= 2.1 && < 3, deepseq >= 1.1 && < 2, bytestring >= 0.9 && < 1,- tagsoup >= 0.6 && < 1,+ tagsoup >= 0.8 && < 1, curl >= 1.3 && < 2
src/Text/XML/HXT/Parser/TagSoup.hs view
@@ -65,8 +65,10 @@ -- the first time they are ecountered, and later always this name is used, -- not a string built by the parser. -type Tags = [Tag]+type STag = Tag String +type Tags = [STag]+ type Context = ([String], NsEnv) type State = Tags@@ -90,7 +92,7 @@ p <- c if p then t else e -lookAhead :: (Tag -> Bool) -> Parser Bool+lookAhead :: (STag -> Bool) -> Parser Bool lookAhead p = P $ \ s -> (not (null s) && p (head s), s) -- ----------------------------------------@@ -138,10 +140,10 @@ -- ---------------------------------------- -- primitive symbol parsers -getTag :: Parser Tag+getTag :: Parser STag getTag = P $ \ (t1:ts1) -> (t1, ts1) -getSym :: (Tag -> a) -> Parser a+getSym :: (STag -> a) -> Parser a getSym f = do t <- getTag return (f t)@@ -185,7 +187,7 @@ -- ---------------------------------------- -- pushback parsers for inserting missing tags -pushBack :: Tag -> Parser ()+pushBack :: STag -> Parser () pushBack t = P $ \ ts -> ((), t:ts) insCls :: String -> Parser ()@@ -238,7 +240,7 @@ -- own entity lookup to prevent problems with & and tagsoup hack for IE -lookupEntity :: Bool -> Bool -> String -> [Tag]+lookupEntity :: Bool -> Bool -> String -> Tags lookupEntity withWarnings _asHtml e0@('#':e) = case lookupNumericEntity e of Just c -> [ TagText [c] ]@@ -249,7 +251,7 @@ lookupEntity withWarnings asHtml e = case (lookup e entities) of- Just x -> [ TagText [toEnum x]]+ Just x -> [TagText [toEnum x]] Nothing -> (TagText $ "&" ++ e ++ ";") : if withWarnings then [TagWarning $ "Unknown entity reference: &" ++ e ++ ";"]@@ -259,13 +261,33 @@ | asHtml = xhtmlEntities | otherwise = xhtmlEntities -- xmlEntities (TODO: xhtml is xml and html) +lookupEntityAttr :: Bool -> Bool -> (String, Bool) -> (String, Tags)+lookupEntityAttr withWarnings asHtml (e, b)+ | null r = (s, r)+ | otherwise = ("&" ++ s ++ [';'|b], r)+ where+ (TagText s) : r = lookupEntity withWarnings asHtml e+ -- ----------------------------------------+{-+ entityData x = case lookupEntity y of+ Just y -> [TagText $ fromChar y]+ Nothing -> [TagText $ fromString $ "&" ++ y ++ ";"+ ,TagWarning $ fromString $ "Unknown entity: " ++ y]+ where y = toString x + entityAttrib (x,b) = case lookupEntity y of+ Just y -> (fromChar y, [])+ Nothing -> (fromString $ "&" ++ y ++ [';'|b], [TagWarning $ fromString $ "Unknown entity: " ++ y])+ where y = toString x+-}+-- ----------------------------------------+ -- | -- Turns all element and attribute names to lower case -- even !DOCTYPE stuff. But this is discarded when parsing the tagsoup -lowerCaseNames :: [Tag] -> [Tag]+lowerCaseNames :: Tags -> Tags lowerCaseNames = map f where@@ -288,12 +310,21 @@ then lowerCaseNames else id )- . parseTagsOptions (parseOptions { optTagWarning = withWarnings- , optLookupEntity = lookupEntity withWarnings asHtml- }- )+ . tagsoupParse ) where+ tagsoupParse :: String -> Tags+ tagsoupParse = parseTagsOptions tagsoupOptions++ tagsoupOptions :: ParseOptions String+ tagsoupOptions = parseOptions' { optTagWarning = withWarnings+ , optEntityData = lookupEntity withWarnings asHtml+ , optEntityAttrib = lookupEntityAttr withWarnings asHtml+ }+ where+ parseOptions' :: ParseOptions String+ parseOptions' = parseOptions+ -- This is essential for lazy parsing: -- the call of "take 1" stops parsing, when the first element is detected -- no check on end of input sequence is required to build this (0- or 1-element list)
src/Text/XML/HXT/Version.hs view
@@ -1,4 +1,4 @@ module Text.XML.HXT.Version where hxt_version :: String-hxt_version = "8.4.0"+hxt_version = "8.4.1"