 sequences.lib accessors io combinators http.client ;
 IN: html.parser.analyzer
 
+TUPLE: link attributes clickable ;
+
 : scrape-html ( url -- vector )
     http-get parse-html ;
 
 : (find-relative)
-    [ >r + dup r> ?nth* [ 2drop f f ] unless ] [ 2drop f ] if ;
+    [ >r + dup r> ?nth* [ 2drop f f ] unless ] [ 2drop f ] if ; inline
 
 : find-relative ( seq quot n -- i elt )
     >r over [ find drop ] dip r> swap pick
-    (find-relative) ;
+    (find-relative) ; inline
 
 : (find-all) ( n seq quot -- )
     2dup >r >r find-from [
         dupd 2array , 1+ r> r> (find-all)
     ] [
         r> r> 3drop
-    ] if* ;
+    ] if* ; inline
 
 : find-all ( seq quot -- alist )
-    [ 0 -rot (find-all) ] { } make ;
+    [ 0 -rot (find-all) ] { } make ; inline
 
 : (find-nth) ( offset seq quot n count -- obj )
     >r >r [ find-from ] 2keep 4 npick [

        ] if
    ] [
        2drop r> r> 2drop
    ] if ;

: find-nth ( seq quot n -- i elt )
    0 -roll 0 (find-nth) ;

: find-nth-relative ( seq quot n offest -- i elt )
    >r [ find-nth ] 3keep 2drop nip r> swap pick
    (find-relative) ;

: remove-blank-text ( vector -- vector' )
    [

    [ [ name>> "a" = ] [ attributes>> "href" swap at ] bi and ]
    find-between-all ;

: <link> ( vector -- link )
    [ first attributes>> ]
    [ [ name>> { text "img" } member? ] filter ] bi
    link boa ;

: link. ( vector -- )
    [ attributes>> "href" swap at write nl ]
    [ clickable>> [ bl bl text>> print ] each nl ] bi ;

: find-by-text ( seq quot -- tag )
    [ dup name>> text = ] prepose find drop ;
