All followers will be synced with the editing block

This commit is contained in:
Tienson Qin
2020-06-29 20:54:22 +08:00
parent b05a2b102a
commit 8e3a8cb67a
7 changed files with 120 additions and 63 deletions

View File

@@ -5,6 +5,7 @@
[frontend.format :as format]
[frontend.utf8 :as utf8]
[medley.core :as medley]
[frontend.config :as config]
[datascript.core :as d]
[clojure.set :as set]))
@@ -67,7 +68,7 @@
(= "Property_Drawer" (first block))))
(defn extract-properties
[[_ properties start-pos end-pos]]
[[_ properties start-pos end-pos :as all]]
{:properties (into {} properties)
:start-pos start-pos
:end-pos end-pos})
@@ -163,7 +164,8 @@
(let [heading (-> (assoc (second block)
:body (vec (reverse heading-body))
:timestamps timestamps
:properties (:properties properties))
:properties (:properties properties)
:properties-meta (dissoc properties :properties))
(assoc-in [:meta :end-pos] last-pos))
heading (with-refs heading)
last-pos' (get-in heading [:meta :pos])
@@ -238,6 +240,7 @@
{:heading/meta meta
:heading/marker (get heading :heading/marker "nil")
:heading/properties (get heading :heading/properties [])
:heading/properties-meta (get heading :heading/properties-meta [])
:heading/file file
:heading/format format
:heading/page page
@@ -268,3 +271,9 @@
:pages pages
:start-pos start-pos
:end-pos (+ start-pos content-length)})))
(defn with-levels
[text format {:heading/keys [level pre-heading?]}]
(let [pattern (config/get-heading-pattern format)
prefix (if pre-heading? "" (str (apply str (repeat level pattern)) " "))]
(str prefix (string/triml text))))