You can be more precise if you use the `tupelo.forest` library for processing tree-like data structures (this will allow you to avoid the trailing `nil` values, for example). Please see the docs <https://github.com/cloojure/tupelo/blob/master/docs/forest.adoc>, and also the numerous examples <https://github.com/cloojure/tupelo/blob/master/test/clj/tst/tupelo/forest_examples.clj> . Alan
On Mon, Dec 16, 2019 at 12:18 PM Alan Thompson <clooj...@gmail.com> wrote: > Quick & dirty technique: > > (ns tst.demo.core > (:use demo.core tupelo.core tupelo.test) > (:require > [clojure.java.io :as io] > [clojure.walk :as walk] > [tupelo.parse.tagsoup :as tagsoup] )) > > (dotest > (let [txt (slurp (io/resource "test.html")) > >> (println txt) > enlive-data (tagsoup/parse txt) > >> (spyx-pretty enlive-data) > found-comment? (atom false) > tx-fn (fn [item] > (when (and (map? item) > (= :comment (:type item)) > (= "more" (:data item))) > (reset! found-comment? true)) > (if @found-comment? > nil > item)) > enlive-keep (walk/prewalk tx-fn enlive-data) ] > (newline) > (spyx-pretty enlive-keep) > ) ) > > > with result: > > ------------------------------- > Clojure 1.10.1 Java 13 > ------------------------------- > > Testing tst.demo.core > <html> > <h1>This is a test </h1> > <!--more--> > <h2>This is only a test </h2> > </html> > > > enlive-data => > {:tag :html, > :attrs {}, > :content > [{:tag :body, > :attrs {}, > :content > [{:tag :h1, :attrs {}, :content ["This is a test "]} > {:type :comment, :data "more"} > {:tag :h2, :attrs {}, :content ["This is only a test "]}]}]} > > enlive-keep => > {:tag :html, > :attrs {}, > :content > [{:tag :body, > :attrs {}, > :content > [{:tag :h1, :attrs {}, :content ["This is a test "]} nil nil]}]} > > > > > > > On Sun, Dec 15, 2019 at 3:44 PM Matching Socks <phill.w...@gmail.com> > wrote: > >> Indeed "lefts" or "rights" will be the key. A transformation is just a >> function (open up enlive's html.clj to see how it works), so you can >> sanity-check yourself by providing a "transformation" that prints out the >> matched nodes. Feel free to regard Enlive's own transformations as mere >> samples. You could match some node (the comment's parent) and replace its >> contents with 2 divs, one selecting content-before the marker comment and >> the other the content-after. >>> >>> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clojure@googlegroups.com >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/clojure/9da515ab-d685-4dbb-91cd-ffdfc29ee23b%40googlegroups.com >> <https://groups.google.com/d/msgid/clojure/9da515ab-d685-4dbb-91cd-ffdfc29ee23b%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/clojure/CAN67zA3QJLGLo6RSo%2BqgSeOyxe2x%3DJusjRi2MLeQx5S-C72Vjw%40mail.gmail.com.