fix: schedule doesn't work well with logbook together

pull/2751/head
Tienson Qin 2021-09-01 10:30:29 +08:00
parent 98cb06b86e
commit 76595cc69b
2 changed files with 10 additions and 7 deletions

View File

@ -339,9 +339,7 @@
content (if (and (seq properties) real-content (not= real-content content))
(property/with-built-in-properties properties content format)
content)
content (->> content
(drawer/remove-logbook)
(drawer/with-logbook block))
content (drawer/with-logbook block content)
content (with-timetracking block content)
first-block? (= left page)
ast (mldoc/->edn (string/trim content) (mldoc/default-config format))
@ -790,6 +788,7 @@
(reduce (fn [content [old new]]
(string/replace content old new))
content))
content (clock/clock-out format content)
content (drawer/insert-drawer
format content "logbook"
(util/format (str (if (= :org format) "-" "*")

View File

@ -57,7 +57,7 @@
before (subvec lines 0 (inc properties-count))
after (rest lines)]
(string/join "\n" (concat before [drawer] after))))
(str title "\n" drawer body)))
(str title "\n" drawer "\n" body)))
(and has-typ-drawer?
(>= start-idx 0) (> end-idx 0) (> end-idx start-idx))
@ -114,12 +114,16 @@
(defn with-logbook
[block content]
(let [body (:block/body block)
(let [new-clocks (last (get-drawer-ast (:block/format block) content "logbook"))
body (:block/body block)
logbook (get-logbook body)]
(if logbook
(let [clocks (map string/trim (last logbook))
(let [content (remove-logbook content)
clocks (->> (concat new-clocks (last logbook))
(distinct))
clocks (->> (map string/trim clocks)
(remove string/blank?))
logbook (->> (concat [":LOGBOOK:"] clocks [":END:"])
(remove string/blank?)
(string/join "\n"))
lines (string/split-lines content)]
(if (:block/title block)