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