فهرست منبع

fix: Import JSON from Roam still using "#" instead of "-"

close #2136
Tienson Qin 4 سال پیش
والد
کامیت
6b187d3545
1فایلهای تغییر یافته به همراه7 افزوده شده و 4 حذف شده
  1. 7 4
      src/main/frontend/external/roam.cljc

+ 7 - 4
src/main/frontend/external/roam.cljc

@@ -20,7 +20,7 @@
 ;; DONE: 2. merge pages with same names (case-sensitive)
 ;; DONE: 2. merge pages with same names (case-sensitive)
 ;; DONE: 3. mldoc add support to roam research macros, or we can transform here.
 ;; DONE: 3. mldoc add support to roam research macros, or we can transform here.
 ;; DONE: 4. mldoc add support to nested links
 ;; DONE: 4. mldoc add support to nested links
-;; TODO: 5. Roam attributes -> properties
+;; DONE: 5. Roam attributes -> properties
 ;; TODO: 6. hiccup
 ;; TODO: 6. hiccup
 
 
 (defonce uid-pattern #"\(\(([a-zA-Z0-9_\\-]{6,24})\)\)")
 (defonce uid-pattern #"\(\(([a-zA-Z0-9_\\-]{6,24})\)\)")
@@ -82,7 +82,10 @@
   (when-not (and (get @uid->uuid uid) uid)
   (when-not (and (get @uid->uuid uid) uid)
     (swap! uid->uuid assoc uid (medley/random-uuid)))
     (swap! uid->uuid assoc uid (medley/random-uuid)))
   (let [children-text (children->text children (inc level))
   (let [children-text (children->text children (inc level))
-        level-pattern (apply str (repeat level "#"))
+        level-pattern (str (apply str (repeat level "\t"))
+                           (if (zero? level)
+                             "-"
+                             " -"))
         properties (when (contains? @all-refed-uids uid)
         properties (when (contains? @all-refed-uids uid)
                      (str
                      (str
                       (util/format "id:: %s"
                       (util/format "id:: %s"
@@ -101,9 +104,9 @@
 (defn ->file
 (defn ->file
   [page-data]
   [page-data]
   (let [{:keys [create-time title children edit-time]} page-data
   (let [{:keys [create-time title children edit-time]} page-data
-        initial-level 2
+        initial-level 1
         text (when (seq children)
         text (when (seq children)
-               (when-let [text (children->text children initial-level)]
+               (when-let [text (children->text children (dec initial-level))]
                  (let [front-matter (util/format "---\ntitle: %s\n---\n\n" title)]
                  (let [front-matter (util/format "---\ntitle: %s\n---\n\n" title)]
                    (str front-matter (transform text)))))]
                    (str front-matter (transform text)))))]
     (when (and (not (string/blank? title))
     (when (and (not (string/blank? title))