]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/html/parser/analyzer/analyzer.factor
Delete empty unit tests files, remove 1- and 1+, reorder IN: lines in a lot of places...
[factor.git] / extra / html / parser / analyzer / analyzer.factor
index b344ce160f4c64ad9de06f9ded2e05b0a5c07d44..d206ae5f45110a4901429b911f5ef8cc7aada0f8 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs html.parser kernel math sequences strings ascii
-arrays generalizations shuffle unicode.case namespaces make
+arrays generalizations shuffle namespaces make
 splitting http accessors io combinators http.client urls
-urls.encoding fry prettyprint ;
+urls.encoding fry prettyprint sets ;
 IN: html.parser.analyzer
 
 TUPLE: link attributes clickable ;
@@ -16,7 +16,7 @@ TUPLE: link attributes clickable ;
 
 : find-nth ( seq quot n -- i elt )
     [ <enum> >alist ] 2dip -rot
-    '[ _ [ second @ ] find-from rot drop swap 1+ ]
+    '[ _ [ second @ ] find-from rot drop swap 1 + ]
     [ f 0 ] 2dip times drop first2 ; inline
 
 : find-first-name ( vector string -- i/f tag/f )
@@ -29,7 +29,7 @@ TUPLE: link attributes clickable ;
 : find-between* ( vector i/f tag/f -- vector )
     over integer? [
         [ tail-slice ] [ name>> ] bi*
-        dupd find-matching-close drop dup [ 1+ ] when
+        dupd find-matching-close drop dup [ 1 + ] when
         [ head ] [ first ] if*
     ] [
         3drop V{ } clone
@@ -126,7 +126,17 @@ TUPLE: link attributes clickable ;
     [ [
         [ name>> "a" = ]
         [ attributes>> "href" swap key? ] bi and ] filter
-    ] map sift [ [ attributes>> "href" swap at ] map ] map concat ;
+    ] map sift
+    [ [ attributes>> "href" swap at ] map ] map concat
+    [ >url ] map ;
+
+: find-frame-links ( vector -- vector' )
+    [ name>> "frame" = ] find-between-all
+    [ [ attributes>> "src" swap at ] map sift ] map concat sift
+    [ >url ] map ;
+
+: find-all-links ( vector -- vector' )
+    [ find-hrefs ] [ find-frame-links ] bi append prune ;
 
 : find-forms ( vector -- vector' )
     "form" over find-opening-tags-by-name