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

close #2136
pull/2159/head
Tienson Qin 2021-06-10 19:16:54 +08:00
parent 40c229a360
commit 6b187d3545
1 changed files with 7 additions and 4 deletions

View File

@ -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))