mirror of
https://github.com/logseq/logseq.git
synced 2026-05-29 23:19:38 +00:00
feat(copy-as/export): add option: remove-properties
This commit is contained in:
@@ -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")}}
|
||||
|
||||
@@ -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}})
|
||||
|
||||
|
||||
@@ -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))]}
|
||||
|
||||
@@ -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))]}
|
||||
|
||||
@@ -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))]}
|
||||
|
||||
Reference in New Issue
Block a user