소스 검색

fix: importing namespaced tags with spaces

Fixes https://github.com/logseq/db-test/issues/210. Also fix invalid
EDN class db-ident related to this
Gabriel Horner 11 달 전
부모
커밋
88d74cb71f

+ 1 - 1
deps/db/src/logseq/db/frontend/db_ident.cljc

@@ -68,7 +68,7 @@
          :cljs (exists? js/process)
          :default false)
     ;; So that we don't have to change :user.{property|class} in our tests
-    (keyword user-namespace (-> name-string (string/replace "/" "-") (string/replace-first #"^\d" "NUM-")))
+    (keyword user-namespace (-> name-string (string/replace #"/|\s+" "-") (string/replace-first #"^(\d)" "NUM-$1")))
     (keyword user-namespace
              (str
               (->> (filter #(re-find #"[0-9a-zA-Z-]{1}" %) (seq name-string)) (apply str))

+ 6 - 4
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -50,11 +50,13 @@
             :block/name (common-util/page-name-sanity-lc new-title)})))
 
 (defn- get-page-uuid [page-names-to-uuids page-name ex-data']
-  (or (get @page-names-to-uuids (if (string/includes? (str page-name) "#")
-                                  (string/lower-case (gp-block/sanitize-hashtag-name page-name))
-                                  page-name))
+  (or (get @page-names-to-uuids (some-> (if (string/includes? (str page-name) "#")
+                                          (string/lower-case (gp-block/sanitize-hashtag-name page-name))
+                                          page-name)
+                                        string/trimr))
       (throw (ex-info (str "No uuid found for page name " (pr-str page-name))
-                      (merge ex-data' {:page-name page-name})))))
+                      (merge ex-data' {:page-name page-name
+                                       :page-names (sort (keys @page-names-to-uuids))})))))
 
 (defn- replace-namespace-with-parent [block page-names-to-uuids]
   (if (:block/namespace block)

+ 2 - 2
deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs

@@ -197,7 +197,7 @@
                   #_(map #(select-keys % [:block/title :block/tags]))
                   count))
           "Correct number of pages with block content")
-      (is (= 12 (->> @conn
+      (is (= 13 (->> @conn
                      (d/q '[:find [?ident ...]
                             :where [?b :block/tags :logseq.class/Tag] [?b :db/ident ?ident] (not [?b :logseq.property/built-in?])])
                      count))
@@ -270,7 +270,7 @@
       (is (= {:user.property/prop-bool true
               :user.property/prop-num 5
               :user.property/prop-string "yeehaw"
-              :block/tags [:logseq.class/Page]}
+              :block/tags [:logseq.class/Page :user.class/Some---Namespace]}
              (readable-properties @conn (db-test/find-page-by-title @conn "some page")))
           "Existing page has correct properties")
 

+ 1 - 0
deps/graph-parser/test/resources/exporter-test-graph/pages/some page.md

@@ -1,5 +1,6 @@
 prop-string:: yeehaw
 prop-num:: 5
 prop-bool:: true
+tags:: [[Some / Namespace ]]
 
 - has some content