packages feed

tagsoup 0.10 → 0.10.1

raw patch · 4 files changed

+26/−4 lines, 4 files

Files

TagSoup/Test.hs view
@@ -180,7 +180,8 @@     rp "<?xml foo?>" === "<?xml foo ?>"     rp "<?xml foo?>" === "<?xml foo ?>"     rp "<!-- neil -->" === "<!-- neil -->"-    escapeHTML "this is a &\" <test>" === "this is a &amp;&quot; &lt;test&gt;"+    rp "<a test=\"a&apos;b\">" === "<a test=\"a'b\">"+    escapeHTML "this is a &\" <test> '" === "this is a &amp;&quot; &lt;test&gt; '"     check $ \(HTML x) -> let y = rp x in rp y == (y :: String)      
Text/HTML/TagSoup/Render.hs view
@@ -26,10 +26,10 @@     }  --- | Replace the four characters @&\"\<\>@ with their HTML entities.+-- | Replace the four characters @&\"\<\>@ with their HTML entities (the list from 'xmlEntities'). escapeHTML :: StringLike str => str -> str escapeHTML = fromString . concatMap esc1 . toString-    where esc = IntMap.fromList [(b, "&"++a++";") | (a,b) <- htmlEntities]+    where esc = IntMap.fromList [(b, "&"++a++";") | (a,b) <- xmlEntities]           esc1 x = IntMap.findWithDefault [x] (ord x) esc  
Text/HTML/TagSoup/Tree.hs view
@@ -61,6 +61,19 @@         f (TagLeaf x) = [x]  +-- | This operation is based on the Uniplate @universe@ function. Given a+--   list of trees, it returns those trees, and all the children trees at+--   any level. For example:+--+-- > universeTree+-- >    [TagBranch "a" [("href","url")] [TagBranch "b" [] [TagLeaf (TagText "text")]]]+-- > == [TagBranch "a" [("href","url")] [TagBranch "b" [] [TagLeaf (TagText "text")]]]+-- >    ,TagBranch "b" [] [TagLeaf (TagText "text")]]+--+--   This operation is particularly useful for queries. To collect all @\"a\"@+--   tags in a tree, simply do:+--+-- > [x | x@(TagTree "a" _ _) <- universeTree tree] universeTree :: [TagTree str] -> [TagTree str] universeTree = concatMap f     where@@ -68,6 +81,14 @@         f x = [x]  +-- | This operation is based on the Uniplate @transform@ function. Given a+--   list of trees, it applies the function to every tree in a bottom-up+--   manner. This operation is useful for manipulating a tree - for example+--   to make all tag names upper case:+--+-- > upperCase = transformTree f+-- >   where f (TagBranch name atts inner) = [TagBranch (map toUpper name) atts inner]+-- >         f x = x transformTree :: (TagTree str -> [TagTree str]) -> [TagTree str] -> [TagTree str] transformTree act = concatMap f     where
tagsoup.cabal view
@@ -1,6 +1,6 @@ cabal-version:  >= 1.6 name:           tagsoup-version:        0.10+version:        0.10.1 copyright:      Neil Mitchell 2006-2010 author:         Neil Mitchell <ndmitchell@gmail.com> maintainer:     Neil Mitchell <ndmitchell@gmail.com>