diff --git a/src/main/frontend/handler/export/html.cljs b/src/main/frontend/handler/export/html.cljs
index 1c36fad9da..510c480553 100644
--- a/src/main/frontend/handler/export/html.cljs
+++ b/src/main/frontend/handler/export/html.cljs
@@ -371,15 +371,21 @@
;;; export fns
(defn- export-helper
[content format options]
- (let [remove-options (set (:remove-options options))]
+ (let [remove-options (set (:remove-options options))
+ other-options (:other-options options)]
(binding [*state* (merge *state*
{:export-options
{:remove-emphasis? (contains? remove-options :emphasis)
:remove-page-ref-brackets? (contains? remove-options :page-ref)
- :remove-tags? (contains? remove-options :tag)}})]
+ :remove-tags? (contains? remove-options :tag)
+ :keep-only-level<=N (:keep-only-level<=N other-options)}})]
(let [ast (util/profile :gp-mldoc/->edn (gp-mldoc/->edn content (gp-mldoc/default-config format)))
ast (util/profile :remove-pos (mapv common/remove-block-ast-pos ast))
ast (removev common/Properties-block-ast? ast)
+ keep-level<=n (get-in *state* [:export-options :keep-only-level<=N])
+ ast (if (pos? keep-level<=n)
+ (common/keep-only-level<=n ast keep-level<=n)
+ ast)
ast* (util/profile :replace-block&page-reference&embed (common/replace-block&page-reference&embed ast))
ast** (if (= "no-indent" (get-in *state* [:export-options :indent-style]))
(util/profile :replace-Heading-with-Paragraph (mapv common/replace-Heading-with-Paragraph ast*))
diff --git a/src/main/frontend/handler/export/opml.cljs b/src/main/frontend/handler/export/opml.cljs
index 8e034cad4c..d8d7914ade 100644
--- a/src/main/frontend/handler/export/opml.cljs
+++ b/src/main/frontend/handler/export/opml.cljs
@@ -390,16 +390,22 @@
;;; export fns
(defn- export-helper
[content format options]
- (let [remove-options (set (:remove-options options))]
+ (let [remove-options (set (:remove-options options))
+ other-options (:other-options options)]
(binding [*state* (merge *state*
{:export-options
{:remove-emphasis? (contains? remove-options :emphasis)
:remove-page-ref-brackets? (contains? remove-options :page-ref)
- :remove-tags? (contains? remove-options :tag)}})
+ :remove-tags? (contains? remove-options :tag)
+ :keep-only-level<=N (:keep-only-level<=N other-options)}})
*opml-state* *opml-state*]
(let [ast (gp-mldoc/->edn content (gp-mldoc/default-config format))
ast (mapv common/remove-block-ast-pos ast)
ast (removev common/Properties-block-ast? ast)
+ keep-level<=n (get-in *state* [:export-options :keep-only-level<=N])
+ ast (if (pos? keep-level<=n)
+ (common/keep-only-level<=n ast keep-level<=n)
+ ast)
ast* (common/replace-block&page-reference&embed ast)
ast** (if (= "no-indent" (get-in *state* [:export-options :indent-style]))
(mapv common/replace-Heading-with-Paragraph ast*)
diff --git a/src/main/frontend/handler/export/text.cljs b/src/main/frontend/handler/export/text.cljs
index 4faaaab4a4..63150e5a35 100644
--- a/src/main/frontend/handler/export/text.cljs
+++ b/src/main/frontend/handler/export/text.cljs
@@ -428,9 +428,9 @@
ast (mapv common/remove-block-ast-pos ast)
ast (removev common/Properties-block-ast? ast)
keep-level<=n (get-in *state* [:export-options :keep-only-level<=N])
- ast (if (= :all keep-level<=n)
- ast
- (common/keep-only-level<=n ast keep-level<=n))
+ ast (if (pos? keep-level<=n)
+ (common/keep-only-level<=n ast keep-level<=n)
+ ast)
ast* (common/replace-block&page-reference&embed ast)
ast** (if (= "no-indent" (get-in *state* [:export-options :indent-style]))
(mapv common/replace-Heading-with-Paragraph ast*)
@@ -453,7 +453,8 @@
(defn export-blocks-as-markdown
"options:
:indent-style \"dashes\" | \"spaces\" | \"no-indent\"
- :remove-options [:emphasis :page-ref :tag]"
+ :remove-options [:emphasis :page-ref :tag]
+ :other-options {:keep-only-level<=N int}"
[repo root-block-uuids-or-page-name options]
{:pre [(or (coll? root-block-uuids-or-page-name)
(string? root-block-uuids-or-page-name))]}