mirror of https://github.com/logseq/logseq
enhance(property): remove empty properties drawer
parent
a76df9ce97
commit
229c7f2594
|
@ -792,7 +792,7 @@
|
|||
content (drawer/insert-drawer
|
||||
format content "logbook"
|
||||
(util/format (str (if (= :org format) "-" "*")
|
||||
" State \"DONE\" from \"%s\" [%s]")
|
||||
" State \"DONE\" from \"%s\" [%s]")
|
||||
marker
|
||||
(date/get-date-time-string-3)))]
|
||||
content)
|
||||
|
@ -952,6 +952,7 @@
|
|||
content (if (nil? value)
|
||||
(property/remove-property format key content)
|
||||
(property/insert-property format content key value))
|
||||
content (property/remove-empty-properties content)
|
||||
block (outliner-core/block {:block/uuid block-id
|
||||
:block/properties properties
|
||||
:block/content content})
|
||||
|
|
|
@ -75,6 +75,16 @@
|
|||
(js/console.error e)
|
||||
content))))
|
||||
|
||||
(defn empty-drawer-typ?
|
||||
[format content typ]
|
||||
(when-let [drawer-ast (get-drawer-ast format content typ)]
|
||||
(empty? (last drawer-ast))))
|
||||
|
||||
(defn remove-empty-drawer
|
||||
[format content typ]
|
||||
(if (empty-drawer-typ? format content typ)
|
||||
(string/replace content (build-drawer-str typ) "")))
|
||||
|
||||
(defn contains-logbook?
|
||||
[content]
|
||||
(and (util/safe-re-find (re-pattern (str "(?i)" logbook-start)) content)
|
||||
|
|
|
@ -38,6 +38,14 @@
|
|||
(and (string/includes? content properties-start)
|
||||
(util/safe-re-find properties-end-pattern content)))
|
||||
|
||||
(defn remove-empty-properties
|
||||
[content]
|
||||
(if (contains-properties? content)
|
||||
(string/replace content
|
||||
(re-pattern ":PROPERTIES:\n:END:\n*")
|
||||
"")
|
||||
content))
|
||||
|
||||
(defn simplified-property?
|
||||
[line]
|
||||
(boolean
|
||||
|
|
Loading…
Reference in New Issue