mirror of https://github.com/logseq/logseq
fix: link property causes wrong pages creation
parent
965bedf4fa
commit
f02c21c95b
|
@ -159,7 +159,8 @@
|
|||
(contains? #{:background-color :background_color} (keyword k))))
|
||||
(map last)
|
||||
(map (fn [v]
|
||||
(when (string? v)
|
||||
(when (and (string? v)
|
||||
(not (mldoc/link? format v)))
|
||||
(let [v (string/trim v)
|
||||
result (text/split-page-refs-without-brackets v {:un-brackets? false})]
|
||||
(if (coll? result)
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
[lambdaisland.glogi :as log]
|
||||
[medley.core :as medley]
|
||||
["mldoc" :as mldoc :refer [Mldoc]]
|
||||
[linked.core :as linked]))
|
||||
[linked.core :as linked]
|
||||
[frontend.config :as config]))
|
||||
|
||||
(defonce parseJson (gobj/get Mldoc "parseJson"))
|
||||
(defonce parseInlineJson (gobj/get Mldoc "parseInlineJson"))
|
||||
|
@ -263,6 +264,17 @@
|
|||
(defn link?
|
||||
[format link]
|
||||
(when (string? link)
|
||||
(let [[type link] (first (inline->edn link (default-config format)))]
|
||||
(let [[type link] (first (inline->edn link (default-config format)))
|
||||
[ref-type ref-value] (:url link)]
|
||||
(and (= "Link" type)
|
||||
(not (contains? #{"Page_ref" "Block_ref"} (first (:url link))))))))
|
||||
(or
|
||||
;; 1. url
|
||||
(not (contains? #{"Page_ref" "Block_ref"} ref-type))
|
||||
|
||||
(and (contains? #{"Page_ref"} ref-type)
|
||||
(or
|
||||
;; 2. excalidraw link
|
||||
(config/draw? ref-value)
|
||||
|
||||
;; 3. local asset link
|
||||
(boolean (config/local-asset? ref-value)))))))))
|
||||
|
|
|
@ -22,12 +22,16 @@
|
|||
(testing "org links without labels"
|
||||
(are [x y] (= (mldoc/link? :org x) y)
|
||||
"[[http://www.google.com]]" true
|
||||
"[[https://www.google.com]]" true))
|
||||
"[[https://www.google.com]]" true
|
||||
"[[draws/2022-03-06-15-00-28.excalidraw]]" true
|
||||
"[[assets/2022-03-06-15-00-28.pdf]]" true))
|
||||
|
||||
(testing "markdown links"
|
||||
(are [x y] (= (mldoc/link? :markdown x) y)
|
||||
"[google](http://www.google.com)" true
|
||||
"[google](https://www.google.com)" true))
|
||||
"[google](https://www.google.com)" true
|
||||
"[[draws/2022-03-06-15-00-28.excalidraw]]" true
|
||||
"![a pdf](assets/2022-03-06-15-00-28.pdf)" true))
|
||||
|
||||
;; https://github.com/logseq/logseq/issues/4308
|
||||
(testing "parsing links should be finished"
|
||||
|
|
Loading…
Reference in New Issue