scalpel 0.3.0 → 0.3.0.1
raw patch · 5 files changed
+33/−6 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- scalpel.cabal +3/−2
- src/Text/HTML/Scalpel/Internal/Scrape.hs +1/−1
- src/Text/HTML/Scalpel/Internal/Select/Types.hs +5/−3
- tests/TestMain.hs +20/−0
CHANGELOG.md view
@@ -2,6 +2,10 @@ ## HEAD +## 0.3.0.1++- Make tag and attribute matching case-insensitive.+ ## 0.3.0 - Added benchmarks and many optimizations.
scalpel.cabal view
@@ -1,5 +1,5 @@ name: scalpel-version: 0.3.0+version: 0.3.0.1 synopsis: A high level web scraping library for Haskell. description: Scalpel is a web scraping library inspired by libraries like Parsec and@@ -24,7 +24,7 @@ source-repository this type: git location: https://github.com/fimad/scalpel.git- tag: v0.3.0+ tag: v0.3.0.1 library other-extensions:@@ -60,6 +60,7 @@ type: exitcode-stdio-1.0 main-is: TestMain.hs hs-source-dirs: tests/+ default-language: Haskell2010 build-depends: HUnit , base >= 4.6 && < 5
src/Text/HTML/Scalpel/Internal/Scrape.hs view
@@ -59,7 +59,7 @@ -- 'TagSoup.Tag's and produces an optional value. scrape :: (Ord str, TagSoup.StringLike str) => Scraper str a -> [TagSoup.Tag str] -> Maybe a-scrape s = scrapeOffsets s . tagWithOffset+scrape s = scrapeOffsets s . tagWithOffset . TagSoup.canonicalizeTags -- | The 'chroot' function takes a selector and an inner scraper and executes -- the inner scraper as if it were scraping a document that consists solely of
src/Text/HTML/Scalpel/Internal/Select/Types.hs view
@@ -14,6 +14,8 @@ , SelectNode (..) ) where +import Data.Char (toLower)+ import qualified Text.HTML.TagSoup as TagSoup import qualified Text.StringLike as TagSoup @@ -68,7 +70,7 @@ toSelector = id instance Selectable String where- toSelector node = MkSelector [SelectNode node []]+ toSelector node = MkSelector [SelectNode (map toLower node) []] instance Selectable Any where toSelector = const (MkSelector [SelectAny []])@@ -77,10 +79,10 @@ matchKey = const . const True instance AttributeName String where- matchKey = (==) . TagSoup.fromString+ matchKey = (==) . TagSoup.fromString . map toLower instance TagName Any where toSelectNode = const SelectAny instance TagName String where- toSelectNode = SelectNode . TagSoup.fromString+ toSelectNode = SelectNode . TagSoup.fromString . map toLower
tests/TestMain.hs view
@@ -158,6 +158,26 @@ , scrapeTest "<img src='foobar'>" (Just "foobar") (attr "src" "img") , scrapeTest "<img src='foobar' />" (Just "foobar") (attr "src" "img")++ , scrapeTest+ "<a>foo</a><A>bar</A>"+ (Just ["foo", "bar"])+ (texts "a")++ , scrapeTest+ "<a>foo</a><A>bar</A>"+ (Just ["foo", "bar"])+ (texts "A")++ , scrapeTest+ "<a B=C>foo</a>"+ (Just ["foo"])+ (texts $ "A" @: ["b" @= "C"])++ , scrapeTest+ "<a B=C>foo</a>"+ Nothing+ (texts $ "A" @: ["b" @= "c"]) ] scrapeTest :: (Eq a, Show a) => String -> Maybe a -> Scraper String a -> Test