This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user