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 <[email protected]> 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 [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected].
> 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 [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/clojure/CAN67zA26pf4SRjxM0mh4%2B2wKCsHX69Kg5rAqiqBqzHMisTUwCw%40mail.gmail.com.