mirror of https://github.com/logseq/logseq
fix: insert properties will truncate other properties if there's any empty property (#9117)
fix: insert properties not working when there's any empty propertypull/9138/head
parent
9adb8646b0
commit
b359718f4a
|
@ -174,9 +174,6 @@
|
|||
(name k))
|
||||
v'
|
||||
|
||||
(string/blank? v')
|
||||
nil
|
||||
|
||||
(gp-util/wrapped-by-quotes? v')
|
||||
v'
|
||||
|
||||
|
|
|
@ -45,13 +45,13 @@
|
|||
[line]
|
||||
(boolean
|
||||
(and (string? line)
|
||||
(re-find (re-pattern (str "^\\s?[^ ]+" gp-property/colons " ")) line))))
|
||||
(re-find (re-pattern (str "^\\s?[^ ]+" gp-property/colons)) line))))
|
||||
|
||||
(defn front-matter-property?
|
||||
[line]
|
||||
(boolean
|
||||
(and (string? line)
|
||||
(util/safe-re-find #"^\s*[^ ]+: " line))))
|
||||
(util/safe-re-find #"^\s*[^ ]+:" line))))
|
||||
|
||||
(defn get-property-key
|
||||
[line format]
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
|
||||
(is (= {:title 98
|
||||
:alias 6
|
||||
:tags 2 :permalink 2
|
||||
:tags 3 :permalink 2
|
||||
:name 1 :type 1 :related 1 :sample 1 :click 1 :id 1 :example 1}
|
||||
(docs-graph-helper/get-all-page-properties db))
|
||||
"Counts for all page properties")
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
"** hello"
|
||||
|
||||
(property/remove-properties :markdown "** hello\nx:: y\na::b\n")
|
||||
"** hello\na::b"))
|
||||
"** hello"))
|
||||
|
||||
(testing "properties with blank lines"
|
||||
(are [x y] (= x y)
|
||||
|
@ -152,7 +152,19 @@ SCHEDULED: <2021-10-25 Mon>\n:PROPERTIES:\n:a: b\n:END:\nworld\n" "c" "d")
|
|||
"a\nfoo:: [[bar]], [[baz]]\nb"
|
||||
|
||||
(property/insert-properties :markdown "" {:foo "\"bar, baz\""})
|
||||
"foo:: \"bar, baz\""))
|
||||
"foo:: \"bar, baz\""
|
||||
|
||||
(property/insert-properties :markdown "abcd\nempty::" {:id "123" :foo "bar"})
|
||||
"abcd\nempty::\nid:: 123\nfoo:: bar"
|
||||
|
||||
(property/insert-properties :markdown "abcd\nempty:: " {:id "123" :foo "bar"})
|
||||
"abcd\nempty:: \nid:: 123\nfoo:: bar"
|
||||
|
||||
(property/insert-properties :markdown "abcd\nempty::" {:id "123"})
|
||||
"abcd\nempty::\nid:: 123"
|
||||
|
||||
(property/insert-properties :markdown "abcd\nempty::\nanother-empty::" {:id "123"})
|
||||
"abcd\nempty::\nanother-empty::\nid:: 123"))
|
||||
|
||||
(deftest test-build-properties-str
|
||||
(are [x y] (= (property/build-properties-str :mardown x) y)
|
||||
|
|
Loading…
Reference in New Issue