mirror of
https://github.com/logseq/logseq.git
synced 2026-04-26 23:25:05 +00:00
Convert flat headings to vector of trees
This commit is contained in:
@@ -112,30 +112,6 @@
|
||||
heading)))
|
||||
headings))
|
||||
|
||||
(defn ->nested-headings [col]
|
||||
(loop [coll (rest col)
|
||||
children []
|
||||
result [(first col)]]
|
||||
(cond
|
||||
(empty? coll)
|
||||
result
|
||||
|
||||
(<= (:heading/level (first coll))
|
||||
(:heading/level (last result)))
|
||||
(recur
|
||||
(rest coll)
|
||||
[]
|
||||
(let [last-element (assoc (last result) :heading/children children)]
|
||||
(-> (vec (drop-last result))
|
||||
(conj last-element (first coll)))))
|
||||
|
||||
(> (:heading/level (first coll))
|
||||
(:heading/level (last result)))
|
||||
(recur
|
||||
(rest coll)
|
||||
(->nested-headings (conj children (first coll)))
|
||||
result))))
|
||||
|
||||
(defn extract-headings
|
||||
[blocks last-pos]
|
||||
(loop [headings []
|
||||
|
||||
Reference in New Issue
Block a user