Fork me on GitHub
#meander
<
2024-03-23
>
andersmurphy23:03:27

(m/search [:article
           [:div
            [:nav
             [:div
              [:p "foo"]
              [:p "foo"]]]]
           [:div
            [:div
             [:p "foo"]]]]
  [:article
   . _ ...
   (m/$ [(m/not :nav)
         . _ ...
         (m/$ [:p & _ :as ?el])
         . _ ...])
   . _ ...]
  ?el)
I’m trying to get all the :p tags that are not descendants of :nav tags. I’m using m/not and I understand why it doesn’t work, because it can be satisfied with a :div tag before it sees a :nav tag. Effectively, what I’m looking for is m/never that makes m/$ not return a match if it encounters a :nav tag. Is there some mechanism/operator in Meander to achieve this? Basically, how would you write “never a descendant of” in meander. Thanks.