fix: export indentation for block content

pull/1697/head
Tienson Qin 2021-04-25 19:19:05 +08:00
parent 07f60a7950
commit e69b155ca2
3 changed files with 24 additions and 18 deletions

View File

@ -73,7 +73,7 @@
"ignore": "^5.1.8",
"is-svg": "4.2.2",
"jszip": "^3.5.0",
"mldoc": "0.6.11",
"mldoc": "0.6.13",
"path": "^0.12.7",
"react": "^17.0.1",
"react-dom": "^17.0.1",

View File

@ -15,26 +15,32 @@
[frontend.modules.outliner.tree :as tree]
[promesa.core :as p]))
(defn- indented-block-content
[content spaces-tabs]
(let [lines (string/split-lines content)]
(string/join (str "\n" spaces-tabs) lines)))
(defn transform-content
[{:block/keys [format pre-block? content unordered]} level]
(let [content (or content "")]
(if pre-block?
(string/trim content)
(let [prefix (cond
(= format :org)
(->>
(repeat level "*")
(apply str))
(let [[prefix spaces-tabs]
(cond
(= format :org)
[(->>
(repeat level "*")
(apply str)) ""]
(and (= format :markdown) (not unordered)) ; heading
""
(and (= format :markdown) (not unordered)) ; heading
["" ""]
:else
(str (->>
(repeat (dec level) (state/get-export-bullet-indentation))
(apply str))
"-")) ; TODO:
new-content (string/trim content)]
:else
(let [spaces-tabs (->>
(repeat (dec level) (state/get-export-bullet-indentation))
(apply str))]
[(str spaces-tabs "-") (str spaces-tabs " ")]))
new-content (indented-block-content (string/trim content) spaces-tabs)]
(str prefix " " new-content)))))
(defn tree->file-content

View File

@ -3853,10 +3853,10 @@ mkdirp@^0.5.4, mkdirp@~0.5.1:
dependencies:
minimist "^1.2.5"
mldoc@0.6.11:
version "0.6.11"
resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-0.6.11.tgz#8174ff837a9a66318480061f4f25a795507ef4b6"
integrity sha512-FoGbsqxUEJYXK/K5YtqVOifmxeS93/fvMuSV+WcsrxxQyT/nXRV0biUiqKgKJYoApdhq96p/eNMTKhIfTdI+lw==
mldoc@0.6.13:
version "0.6.13"
resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-0.6.13.tgz#bb8cba40ec512717e06e9dd4a668f4a05d479503"
integrity sha512-Vllx8zxUNB/M2FQJYHyuJ0096JOPhl1idAimp65Fk/vmMkG4DlMC/VWKCtaReHx8lOZ1uGFobkHMlvJOuyOsAA==
dependencies:
yargs "^12.0.2"