diff --git a/src/main/frontend/components/export.cljs b/src/main/frontend/components/export.cljs index 44b5550758..c6bef6e575 100644 --- a/src/main/frontend/components/export.cljs +++ b/src/main/frontend/components/export.cljs @@ -168,10 +168,10 @@ (reset! *content (export-helper root-block-uuids-or-page-name)))}) [:div {:style {:visibility (if (#{:text :html :opml} tp) "visible" "hidden")}} - "remove #tags"] + "remove #tags"]] + [:div.flex.items-center (ui/checkbox {:style {:margin-right 6 - :margin-left "1em" :visibility (if (#{:text} tp) "visible" "hidden")} :checked (boolean (:newline-after-block @*text-other-options)) :on-change (fn [e] @@ -180,7 +180,18 @@ (reset! *text-other-options (state/get-export-block-text-other-options)) (reset! *content (export-helper root-block-uuids-or-page-name)))}) [:div {:style {:visibility (if (#{:text} tp) "visible" "hidden")}} - "newline after block"]] + "newline after block"] + + (ui/checkbox {:style {:margin-right 6 + :margin-left "1em" + :visibility (if (#{:text} tp) "visible" "hidden")} + :checked (contains? @*text-remove-options :property) + :on-change (fn [e] + (state/update-export-block-text-remove-options! e :property) + (reset! *text-remove-options (state/get-export-block-text-remove-options)) + (reset! *content (export-helper root-block-uuids-or-page-name)))}) + [:div {:style {:visibility (if (#{:text} tp) "visible" "hidden")}} + "remove properties"]] [:div.flex.items-center [:label.mr-2 {:style {:visibility (if (#{:text :html :opml} tp) "visible" "hidden")}} diff --git a/src/main/frontend/handler/export/common.cljs b/src/main/frontend/handler/export/common.cljs index 06726aa513..968cc389d4 100644 --- a/src/main/frontend/handler/export/common.cljs +++ b/src/main/frontend/handler/export/common.cljs @@ -49,6 +49,7 @@ :remove-page-ref-brackets? false :remove-emphasis? false :remove-tags? false + :remove-properties? true :keep-only-level<=N :all :newline-after-block false}}) diff --git a/src/main/frontend/handler/export/html.cljs b/src/main/frontend/handler/export/html.cljs index 8c6c9a682c..096c0807c1 100644 --- a/src/main/frontend/handler/export/html.cljs +++ b/src/main/frontend/handler/export/html.cljs @@ -406,8 +406,7 @@ (h/render-html hiccup))))) (defn export-blocks-as-html - "options: - :remove-options [:emphasis :page-ref :tag]" + "options: see also `export-blocks-as-markdown`" [repo root-block-uuids-or-page-name options] {:pre [(or (coll? root-block-uuids-or-page-name) (string? root-block-uuids-or-page-name))]} diff --git a/src/main/frontend/handler/export/opml.cljs b/src/main/frontend/handler/export/opml.cljs index fa000ad979..b9758e936a 100644 --- a/src/main/frontend/handler/export/opml.cljs +++ b/src/main/frontend/handler/export/opml.cljs @@ -426,8 +426,7 @@ (zip-loc->opml hiccup "untitled"))))) (defn export-blocks-as-opml - "options: - :remove-options [:emphasis :page-ref :tag]" + "options: see also `export-blocks-as-markdown`" [repo root-block-uuids-or-page-name options] {:pre [(or (coll? root-block-uuids-or-page-name) (string? root-block-uuids-or-page-name))]} diff --git a/src/main/frontend/handler/export/text.cljs b/src/main/frontend/handler/export/text.cljs index 81fd0da0f8..9fd379eb28 100644 --- a/src/main/frontend/handler/export/text.cljs +++ b/src/main/frontend/handler/export/text.cljs @@ -81,6 +81,16 @@ (not in-list?)) [(newline* 2)])))) +(defn- block-property-drawer + [properties] + (when-not (get-in *state* [:export-options :remove-properties?]) + (let [level (dec (get *state* :current-level 1)) + indent (indent-with-2-spaces level)] + (reduce + (fn [r [k v]] + (conj r indent (raw-text k "::") space (raw-text v) (newline* 1))) + [] properties)))) + (defn- block-example [l] (let [level (dec (get *state* :current-level 1))] @@ -335,7 +345,7 @@ (block-heading ast-content) "List" (block-list ast-content) - ("Directive" "Results" "Property_Drawer" "Export" "CommentBlock" "Custom") + ("Directive" "Results" "Export" "CommentBlock" "Custom") nil "Example" (block-example ast-content) @@ -351,9 +361,8 @@ (block-displayed-math ast-content) "Drawer" (block-drawer (rest block)) - ;; TODO: option: toggle Property_Drawer - ;; "Property_Drawer" - ;; (block-property-drawer ast-content) + "Property_Drawer" + (block-property-drawer ast-content) "Footnote_Definition" (block-footnote-definition (rest block)) "Horizontal_Rule" @@ -434,6 +443,7 @@ :remove-emphasis? (contains? remove-options :emphasis) :remove-page-ref-brackets? (contains? remove-options :page-ref) :remove-tags? (contains? remove-options :tag) + :remove-properties? (contains? remove-options :property) :keep-only-level<=N (:keep-only-level<=N other-options) :newline-after-block (:newline-after-block other-options)}})] (let [ast (gp-mldoc/->edn content (gp-mldoc/default-config format)) @@ -465,8 +475,8 @@ (defn export-blocks-as-markdown "options: :indent-style \"dashes\" | \"spaces\" | \"no-indent\" - :remove-options [:emphasis :page-ref :tag] - :other-options {:keep-only-level<=N int}" + :remove-options [:emphasis :page-ref :tag :property] + :other-options {:keep-only-level<=N int :newline-after-block bool}" [repo root-block-uuids-or-page-name options] {:pre [(or (coll? root-block-uuids-or-page-name) (string? root-block-uuids-or-page-name))]}