From 507da76274cc3ecfbd9545d4a9e28c427c148a97 Mon Sep 17 00:00:00 2001 From: Raveline Date: Mon, 24 Apr 2017 11:05:14 +0200 Subject: [PATCH 1/2] Add test for proper DFS implementation Add a "p" tag with one depth-level more than the others to check that it will be parsed before the next parent sibling. --- scalpel-core/tests/TestMain.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scalpel-core/tests/TestMain.hs b/scalpel-core/tests/TestMain.hs index e330612..7400a7c 100644 --- a/scalpel-core/tests/TestMain.hs +++ b/scalpel-core/tests/TestMain.hs @@ -296,6 +296,11 @@ scrapeTests = "scrapeTests" ~: TestList [ index <- position content <- text anySelector return (index, content)) + + , scrapeTest + "

p1

p2

p3

p4

" + (Just ["p1", "p2", "p3", "p4"]) + (texts "p") ] scrapeTest :: (Eq a, Show a) => String -> Maybe a -> Scraper String a -> Test From 4d5623991f17aea093073582dbcd09039ab3d599 Mon Sep 17 00:00:00 2001 From: Raveline Date: Mon, 24 Apr 2017 11:08:22 +0200 Subject: [PATCH 2/2] Fix non-DFS recursive case on unmatched unique selector --- scalpel-core/src/Text/HTML/Scalpel/Internal/Select.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scalpel-core/src/Text/HTML/Scalpel/Internal/Select.hs b/scalpel-core/src/Text/HTML/Scalpel/Internal/Select.hs index 236cfa6..35f9a09 100644 --- a/scalpel-core/src/Text/HTML/Scalpel/Internal/Select.hs +++ b/scalpel-core/src/Text/HTML/Scalpel/Internal/Select.hs @@ -219,8 +219,8 @@ selectNodes [n] (tags, f : fs, ctx) acc | nodeMatches n info = (shrunkSpec :) $ selectNodes [n] (tags, fs, ctx) $ selectNodes [n] (tags, Tree.subForest f, ctx) acc - | otherwise = selectNodes [n] (tags, fs, ctx) - $ selectNodes [n] (tags, Tree.subForest f, ctx) acc + | otherwise = selectNodes [n] (tags, Tree.subForest f, ctx) + $ selectNodes [n] (tags, fs, ctx) acc where Span lo hi = Tree.rootLabel f shrunkSpec = (