 USING: assocs html.parser kernel math sequences strings ascii
 arrays generalizations shuffle unicode.case namespaces make
 splitting http accessors io combinators http.client urls
-urls.encoding fry ;
+urls.encoding fry prettyprint ;
 IN: html.parser.analyzer
 
 TUPLE: link attributes clickable ;

        [ [ [ blank? ] trim ] change-text ] when
    ] map ;

: find-by-id ( id vector -- vector )
    [ attributes>> "id" swap at = ] with filter ;

: find-by-class ( id vector -- vector )
    [ attributes>> "class" swap at = ] with filter ;

: find-by-name ( str vector -- vector )
    [ >lower ] dip [ name>> = ] with filter ;

: find-by-attribute-key ( key vector -- vector )
    [ >lower ] dip
    [ attributes>> at ] with filter
    sift ;

: find-by-attribute-key-value ( value key vector -- vector )
    [ >lower ] dip
    [ attributes>> at over = ] with filter nip
    sift ;

: find-first-attribute-key-value ( value key vector -- i/f tag/f )
    [ >lower ] dip
    [ attributes>> at over = ] with find rot drop ;

: tag-link ( tag -- link/f )

    swap [ >r first2 r> find-between* ] curry map
    [ [ name>> { "form" "input" } member? ] filter ] map ;

: find-html-objects ( vector string -- vector' )
    dupd find-opening-tags-by-name
    [ first2 find-between* ] curry map ;

: form-action ( vector -- string )
    [ name>> "form" = ] find nip 
