USING: assocs html.parser kernel math sequences strings ascii
- arrays shuffle unicode.case namespaces splitting
- http.server.responders sequences.lib ;
+ arrays shuffle unicode.case namespaces splitting http ;
IN: html.parser.analyzer
- : multi-find* ( n seq quots -- i elt )
- ;
-
- : multi-find ( seq quots -- i elt )
- 0 -rot ;
-
+: (find-relative)
+ [ >r + dup r> ?nth* [ 2drop f f ] unless ] [ 2drop f ] if ;
+
+: find-relative ( seq quot n -- i elt )
+ >r over [ find drop ] dip r> swap pick
+ (find-relative) ;
+
+: (find-all) ( n seq quot -- )
+ 2dup >r >r find* [
+ dupd 2array , 1+ r> r> (find-all)
+ ] [
+ r> r> 3drop
+ ] if* ;
+
+: find-all ( seq quot -- alist )
+ [ 0 -rot (find-all) ] { } make ;
+
+: (find-nth) ( offset seq quot n count -- obj )
+ >r >r [ find* ] 2keep 4 npick [
+ r> r> 1+ 2dup <= [
+ 4drop
+ ] [
+ >r >r >r >r drop 1+ r> r> r> r>
+ (find-nth)
+ ] 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' )
[
dup tag-name text = [