This commit is contained in:
2026-03-10 13:02:37 -06:00
parent 1ff453262d
commit b0a3895a18

View File

@@ -11,7 +11,8 @@
[net.deertopia.doerg.config :as cfg]
[com.rpl.specter :as sp]
[clojure.tools.logging.readable :as lr]
[clojure.zip :as z])
[clojure.zip :as z]
[com.rpl.specter.zipper :as sz])
(:import (java.util UUID))
(:refer-clojure :exclude [read-string]))
@@ -229,6 +230,16 @@
(recur next-loc-read next-loc-write))))
wa-loc))
(defn separated-by-explicit-paragraph-break? [e e]
(= (-> e :position :end :line inc)
(-> e :position :start :line inc)))
(defn swallow [predator prey]
(assert (greater-element? predator))
(-> predator
(update :children #(conj % prey))
(assoc-in [:position :end] (-> prey :position :end))))
(comment
(-> [1 2 3 4]
(neighbourly-mapcat prn) )
@@ -238,18 +249,19 @@
blah
(sp/transform
[postorder-walker
(sp/must :children)
(sp/collect-one sp/VAL)
sp/INDEXED-VALS
#_
#(of-type? (second %) "latex-environment")
#_
sp/ALL
#_
sp/INDEXED-VALS]
(fn [siblings x]
(swap! r #(conj % {:siblings siblings :x x}))
x)
(sp/must :children)]
(fn [children]
(-> children z/vector-zip
(=>> (fn [para-loc]
(let [tex-loc (some-> para-loc z/right)
next-para (some-> tex-loc z/right)]
(when (and (of-type? (z/node para-loc) "paragraph")
(some-> tex-loc z/node
(of-type? "latex-environment")))
(when (separated-by-explicit-paragraph-break?
(z/node para-loc) (z/node tex-loc))
(swap! r #(conj % (z/node para-loc))))))
(z/node para-loc)))))
doc)]
@r))