Make descendant combinators work with an implicit parent
tests.lisp
Fri Dec 4 04:47:58 UTC 2009 pix@kepibu.org
* Make descendant combinators work with an implicit parent
--- old-Oh, Ducks!/tests.lisp 2014-08-17 15:40:43.000000000 +0000
+++ new-Oh, Ducks!/tests.lisp 2014-08-17 15:40:43.000000000 +0000
@@ -69,6 +69,26 @@
"<div>I <i>really</i> <b>like</b> cheese. Do you not <i>dislike</i> cheese?</div>")
(values i))
+;; Sometimes, you want to match a thing inside a thing, in which case
+;; combinators should implicitly assume an unspecified right side means
+;; "whatever element I gave you".
+(match (#T(html (:model dom)
+ ("q" . ?q))
+ "<div><i>ham</i> foo <q>bar <i>baz</i></q> quuz <i>spam</i></div>")
+ (match (#t(html ("> i" . ?i))
+ (first q))
+ i))
+
+;; Note, however, that searches are strictly recursive. So a sibling
+;; combinator won't match.
+;; FIXME: should it?
+(match (#T(html (:model dom)
+ ("q" . ?q))
+ "<div><i>ham</i> foo <q>bar <i>baz</i></q> quuz <i>spam</i></div>")
+ (match (#t(html ("+ i" . ?i))
+ (first q))
+ i))
+
#+LATER?
(match (#t(html ("div::content" . #t(regexp+ "^f(o+)" (?o))))