packages feed

tagsoup 0.13.6 → 0.13.7

raw patch · 6 files changed

+12/−7 lines, 6 files

Files

CHANGES.txt view
@@ -1,5 +1,7 @@ Changelog for TagSoup +0.13.7+    #32, make sure upper case &#X works in lookupEntity 0.13.6     #28, some named entities require a trailing semicolon (e.g. mid) 0.13.5
LICENSE view
@@ -1,4 +1,4 @@-Copyright Neil Mitchell 2006-2015.+Copyright Neil Mitchell 2006-2016. All rights reserved.  Redistribution and use in source and binary forms, with or without
README.md view
@@ -1,4 +1,4 @@-# TagSoup [![Hackage version](https://img.shields.io/hackage/v/tagsoup.svg?label=Hackage)](https://hackage.haskell.org/package/tagsoup) [![Build Status](https://img.shields.io/travis/ndmitchell/tagsoup.svg)](https://travis-ci.org/ndmitchell/tagsoup)+# TagSoup [![Hackage version](https://img.shields.io/hackage/v/tagsoup.svg?label=Hackage)](https://hackage.haskell.org/package/tagsoup) [![Stackage version](https://www.stackage.org/package/tagsoup/badge/lts?label=Stackage)](https://www.stackage.org/package/tagsoup) [![Linux Build Status](https://img.shields.io/travis/ndmitchell/tagsoup.svg?label=Linux%20build)](https://travis-ci.org/ndmitchell/tagsoup) [![Windows Build Status](https://img.shields.io/appveyor/ci/ndmitchell/tagsoup.svg?label=Windows%20build)](https://ci.appveyor.com/project/ndmitchell/tagsoup)  TagSoup is a library for parsing HTML/XML. It supports the HTML 5 specification, and can be used to parse either well-formed XML, or unstructured and malformed HTML from the web. The library also provides useful functions to extract information from an HTML document, making it ideal for screen-scraping. @@ -84,7 +84,7 @@         putStrLn $ "haskell.org has been hit " ++ count ++ " times"         where fromFooter = filter isDigit . innerText . take 2 . dropWhile (~/= "<li id=viewcount>") -Now we start writing the code! The first thing to do is open the required URL, then we parse the code into a list of `Tag`s with `parseTags`. The `fromFooter` function does the interesting thing, and can be read left to right:+Now we start writing the code! The first thing to do is open the required URL, then we parse the code into a list of `Tag`s with `parseTags`. The `fromFooter` function does the interesting thing, and can be read right to left:  * First we throw away everything (`dropWhile`) until we get to an `li` tag containing `id=viewcount`. The `(~==)` operator is different from standard equality, allowing additional attributes to be present. We write `"<li id=viewcount>"` as syntactic sugar for `TagOpen "li" [("id","viewcount")]`. If we just wanted any open tag with the given id we could have written `(~== TagOpen "" [("id","viewcount")])` and this would have matched. Any empty strings in the second element of the match are considered as wildcards. * Next we take two elements, the `<li>` tag and the text node immediately following.
TagSoup/Test.hs view
@@ -116,6 +116,7 @@     parseTags "hello &amp; world" === [TagText "hello & world"]     parseTags "hello &#64; world" === [TagText "hello @ world"]     parseTags "hello &#x40; world" === [TagText "hello @ world"]+    parseTags "hello &#X40; world" === [TagText "hello @ world"]     parseTags "hello &haskell; world" === [TagText "hello &haskell; world"]     parseTags "hello \n\t world" === [TagText "hello \n\t world"]     parseTags "<a href=http://www.google.com>" === [TagOpen "a" [("href","http://www.google.com")]]@@ -214,6 +215,7 @@     lookupNumericEntity "x41" === Just "A"     lookupNumericEntity "x4E" === Just "N"     lookupNumericEntity "x4e" === Just "N"+    lookupNumericEntity "X4e" === Just "N"     lookupNumericEntity "Haskell" === Nothing     lookupNumericEntity "" === Nothing     lookupNumericEntity "89439085908539082" === Nothing
Text/HTML/TagSoup/Entity.hs view
@@ -26,6 +26,7 @@ -- > lookupNumericEntity "x41" == Just "A" -- > lookupNumericEntity "x4E" === Just "N" -- > lookupNumericEntity "x4e" === Just "N"+-- > lookupNumericEntity "X4e" === Just "N" -- > lookupNumericEntity "Haskell" == Nothing -- > lookupNumericEntity "" == Nothing -- > lookupNumericEntity "89439085908539082" == Nothing@@ -33,7 +34,7 @@ lookupNumericEntity = f         -- entity = '&#' [0-9]+ ';' | '&#x' [0-9a-fA-F]+ ';'     where-        f ('x':xs) = g [('0','9'),('a','f'),('A','F')] readHex xs+        f (x:xs) | x `elem` "xX" = g [('0','9'),('a','f'),('A','F')] readHex xs         f xs = g [('0','9')] reads xs          g :: [(Char,Char)] -> ReadS Integer -> String -> Maybe String
tagsoup.cabal view
@@ -1,10 +1,10 @@ cabal-version:  >= 1.6 name:           tagsoup-version:        0.13.6-copyright:      Neil Mitchell 2006-2015+version:        0.13.7+copyright:      Neil Mitchell 2006-2016 author:         Neil Mitchell <ndmitchell@gmail.com> maintainer:     Neil Mitchell <ndmitchell@gmail.com>-homepage:       http://community.haskell.org/~ndm/tagsoup/+homepage:       https://github.com/ndmitchell/tagsoup#readme bug-reports:    https://github.com/ndmitchell/tagsoup/issues license:        BSD3 category:       XML