mirror of https://github.com/logseq/logseq
parent
66439dde68
commit
dcb73b1003
|
@ -560,7 +560,7 @@
|
||||||
properties))
|
properties))
|
||||||
|
|
||||||
(defn- construct-block
|
(defn- construct-block
|
||||||
[block properties timestamps body encoded-content format pos-meta {:keys [block-pattern db date-formatter parse-block]}]
|
[block properties timestamps body encoded-content format pos-meta {:keys [block-pattern db date-formatter parse-block remove-properties?]}]
|
||||||
(let [id (get-custom-id-or-new-id properties)
|
(let [id (get-custom-id-or-new-id properties)
|
||||||
ref-pages-in-properties (->> (:page-refs properties)
|
ref-pages-in-properties (->> (:page-refs properties)
|
||||||
(remove string/blank?))
|
(remove string/blank?))
|
||||||
|
@ -591,8 +591,10 @@
|
||||||
(update :properties-text-values dissoc :collapsed)
|
(update :properties-text-values dissoc :collapsed)
|
||||||
(update :properties-order (fn [keys] (vec (remove #{:collapsed} keys)))))
|
(update :properties-order (fn [keys] (vec (remove #{:collapsed} keys)))))
|
||||||
block)
|
block)
|
||||||
block (assoc block
|
title (cond->> (get-block-content encoded-content block format pos-meta block-pattern)
|
||||||
:block/title (get-block-content encoded-content block format pos-meta block-pattern))
|
remove-properties?
|
||||||
|
(gp-property/remove-properties (:format block)))
|
||||||
|
block (assoc block :block/title title)
|
||||||
block (if (seq timestamps)
|
block (if (seq timestamps)
|
||||||
(merge block (timestamps->scheduled-and-deadline timestamps))
|
(merge block (timestamps->scheduled-and-deadline timestamps))
|
||||||
block)
|
block)
|
||||||
|
@ -679,20 +681,28 @@
|
||||||
(recur headings (rest blocks) (inc block-idx) timestamps properties body))
|
(recur headings (rest blocks) (inc block-idx) timestamps properties body))
|
||||||
|
|
||||||
(heading-block? block)
|
(heading-block? block)
|
||||||
;; in db-graphs don't include property, deadline/scheduled or logbook text in :block/title
|
;; in db-graphs cut multi-line when there is property, deadline/scheduled or logbook text in :block/title
|
||||||
(let [pos-meta' (if (and db-graph-mode?
|
(let [cut-multiline? (and db-graph-mode?
|
||||||
(when-let [prev-block (first (get all-blocks (dec block-idx)))]
|
(when-let [prev-block (first (get all-blocks (dec block-idx)))]
|
||||||
(or (gp-property/properties-ast? prev-block)
|
(or (and (gp-property/properties-ast? prev-block)
|
||||||
|
(not= "Custom" (ffirst (get all-blocks (- block-idx 2)))))
|
||||||
(= ["Drawer" "logbook"] (take 2 prev-block))
|
(= ["Drawer" "logbook"] (take 2 prev-block))
|
||||||
(and (= "Paragraph" (first prev-block))
|
(and (= "Paragraph" (first prev-block))
|
||||||
(seq (set/intersection (set (flatten prev-block)) #{"Deadline" "Scheduled"}))))))
|
(seq (set/intersection (set (flatten prev-block)) #{"Deadline" "Scheduled"}))))))
|
||||||
|
pos-meta' (if cut-multiline?
|
||||||
pos-meta
|
pos-meta
|
||||||
;; fix start_pos
|
;; fix start_pos
|
||||||
(assoc pos-meta :end_pos
|
(assoc pos-meta :end_pos
|
||||||
(if (seq headings)
|
(if (seq headings)
|
||||||
(get-in (last headings) [:meta :start_pos])
|
(get-in (last headings) [:meta :start_pos])
|
||||||
nil)))
|
nil)))
|
||||||
block' (construct-block block properties timestamps body encoded-content format pos-meta' options)
|
;; Remove properties text from custom queries in db graphs
|
||||||
|
options' (assoc options
|
||||||
|
:remove-properties?
|
||||||
|
(and db-graph-mode?
|
||||||
|
(and (gp-property/properties-ast? (first (get all-blocks (dec block-idx))))
|
||||||
|
(= "Custom" (ffirst (get all-blocks (- block-idx 2)))))))
|
||||||
|
block' (construct-block block properties timestamps body encoded-content format pos-meta' options')
|
||||||
block'' (if db-graph-mode?
|
block'' (if db-graph-mode?
|
||||||
block'
|
block'
|
||||||
(assoc block' :macros (extract-macros-from-ast (cons block body))))]
|
(assoc block' :macros (extract-macros-from-ast (cons block body))))]
|
||||||
|
|
|
@ -349,7 +349,9 @@
|
||||||
(testing "multiline blocks"
|
(testing "multiline blocks"
|
||||||
(is (= "|markdown| table|\n|some|thing|" (:block/title (find-block-by-content @conn #"markdown.*table"))))
|
(is (= "|markdown| table|\n|some|thing|" (:block/title (find-block-by-content @conn #"markdown.*table"))))
|
||||||
(is (= "multiline block\na 2nd\nand a 3rd" (:block/title (find-block-by-content @conn #"multiline block"))))
|
(is (= "multiline block\na 2nd\nand a 3rd" (:block/title (find-block-by-content @conn #"multiline block"))))
|
||||||
(is (= "logbook block" (:block/title (find-block-by-content @conn #"logbook block")))))
|
(is (= "logbook block" (:block/title (find-block-by-content @conn #"logbook block"))))
|
||||||
|
(is (is (re-find #"(?s)^Text before\n.*BEGIN_QUERY.*END_QUERY\nText after$"
|
||||||
|
(:block/title (find-block-by-content @conn #":title \"tasks"))))))
|
||||||
|
|
||||||
(testing "block refs and path-refs"
|
(testing "block refs and path-refs"
|
||||||
(let [block (find-block-by-content @conn "old todo block")]
|
(let [block (find-block-by-content @conn "old todo block")]
|
||||||
|
|
|
@ -2,9 +2,3 @@
|
||||||
rating:: 5
|
rating:: 5
|
||||||
- :rating float
|
- :rating float
|
||||||
rating:: 5.5
|
rating:: 5.5
|
||||||
- query-table:: false
|
|
||||||
FIXME
|
|
||||||
#+BEGIN_QUERY
|
|
||||||
{:title "2nd level tasks with `#p1`"
|
|
||||||
:query (and (task todo doing) [[p1]])}
|
|
||||||
#+END_QUERY
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
- test multilines
|
- test multilines in this page
|
||||||
- |markdown| table|
|
- |markdown| table|
|
||||||
|some|thing|
|
|some|thing|
|
||||||
|
- block with props
|
||||||
|
prop-num:: 10
|
||||||
- multiline block
|
- multiline block
|
||||||
a 2nd
|
a 2nd
|
||||||
and a 3rd
|
and a 3rd
|
||||||
|
@ -9,3 +11,11 @@
|
||||||
CLOCK: [2024-08-07 Wed 11:47:50]
|
CLOCK: [2024-08-07 Wed 11:47:50]
|
||||||
CLOCK: [2024-08-07 Wed 11:47:53]
|
CLOCK: [2024-08-07 Wed 11:47:53]
|
||||||
:END:
|
:END:
|
||||||
|
- Text before
|
||||||
|
query-table:: false
|
||||||
|
query-properties:: [:block]
|
||||||
|
#+BEGIN_QUERY
|
||||||
|
{:title "tasks with todo and doing"
|
||||||
|
:query (task todo doing)}
|
||||||
|
#+END_QUERY
|
||||||
|
Text after
|
Loading…
Reference in New Issue