Browse Source

fix: graph md exports have no indent

Affected both graph types
Gabriel Horner 10 months ago
parent
commit
954ec0c721

+ 4 - 3
src/main/frontend/handler/export/common.cljs

@@ -195,12 +195,13 @@
   (state/<invoke-db-worker :thread-api/export-get-debug-datoms repo))
   (state/<invoke-db-worker :thread-api/export-get-debug-datoms repo))
 
 
 (defn <get-all-page->content
 (defn <get-all-page->content
-  [repo]
-  (state/<invoke-db-worker :thread-api/export-get-all-page->content repo))
+  [repo options]
+  (state/<invoke-db-worker :thread-api/export-get-all-page->content repo options))
 
 
 (defn <get-file-contents
 (defn <get-file-contents
   [repo suffix]
   [repo suffix]
-  (p/let [page->content (<get-all-page->content repo)]
+  (p/let [page->content (<get-all-page->content repo
+                                                {:export-bullet-indentation (state/get-export-bullet-indentation)})]
     (clojure.core/map (fn [[page-title content]]
     (clojure.core/map (fn [[page-title content]]
                         {:path (str page-title "." suffix)
                         {:path (str page-title "." suffix)
                          :content content
                          :content content

+ 3 - 4
src/main/frontend/handler/export/text.cljs

@@ -1,6 +1,5 @@
 (ns frontend.handler.export.text
 (ns frontend.handler.export.text
   "export blocks/pages as text"
   "export blocks/pages as text"
-  (:refer-clojure :exclude [map filter mapcat concat remove newline])
   (:require [clojure.string :as string]
   (:require [clojure.string :as string]
             [frontend.config :as config]
             [frontend.config :as config]
             [frontend.db :as db]
             [frontend.db :as db]
@@ -545,9 +544,9 @@
 (defn export-repo-as-markdown!
 (defn export-repo-as-markdown!
   "TODO: indent-style and remove-options"
   "TODO: indent-style and remove-options"
   [repo]
   [repo]
-  (p/let [files (util/profile :get-file-content (common/<get-file-contents repo "md"))]
-    (when (seq files)
-      (let [files (export-files-as-markdown files nil)
+  (p/let [files* (util/profile :get-file-content (common/<get-file-contents repo "md"))]
+    (when (seq files*)
+      (let [files (export-files-as-markdown files* nil)
             repo' (if (config/db-based-graph? repo)
             repo' (if (config/db-based-graph? repo)
                     (string/replace repo config/db-version-prefix "")
                     (string/replace repo config/db-version-prefix "")
                     (path/basename repo))
                     (path/basename repo))

+ 2 - 2
src/main/frontend/worker/db_worker.cljs

@@ -731,9 +731,9 @@
     (worker-export/get-all-pages repo @conn)))
     (worker-export/get-all-pages repo @conn)))
 
 
 (def-thread-api :thread-api/export-get-all-page->content
 (def-thread-api :thread-api/export-get-all-page->content
-  [repo]
+  [repo options]
   (when-let [conn (worker-state/get-datascript-conn repo)]
   (when-let [conn (worker-state/get-datascript-conn repo)]
-    (worker-export/get-all-page->content repo @conn)))
+    (worker-export/get-all-page->content repo @conn options)))
 
 
 (def-thread-api :thread-api/undo
 (def-thread-api :thread-api/undo
   [repo _page-block-uuid-str]
   [repo _page-block-uuid-str]

+ 2 - 2
src/main/frontend/worker/export.cljs

@@ -46,7 +46,7 @@
                 (assoc page' :block/children children))))))
                 (assoc page' :block/children children))))))
 
 
 (defn get-all-page->content
 (defn get-all-page->content
-  [repo db]
+  [repo db options]
   (let [filter-fn (if (ldb/db-based-graph? db)
   (let [filter-fn (if (ldb/db-based-graph? db)
                     (fn [ent]
                     (fn [ent]
                       (or (not (:logseq.property/built-in? ent))
                       (or (not (:logseq.property/built-in? ent))
@@ -57,7 +57,7 @@
          (filter filter-fn)
          (filter filter-fn)
          (map (fn [e]
          (map (fn [e]
                 [(:block/title e)
                 [(:block/title e)
-                 (common-file/block->content repo db (:block/uuid e) {} {})])))))
+                 (common-file/block->content repo db (:block/uuid e) {} options)])))))
 
 
 (defn get-debug-datoms
 (defn get-debug-datoms
   [conn ^Object db]
   [conn ^Object db]