mirror of https://github.com/logseq/logseq
fix: Extra space and tab characters will be inserted into the file
close #2108 close #2057pull/2122/head
parent
7915cf41b4
commit
7ef9150e08
|
@ -75,7 +75,7 @@
|
|||
"ignore": "^5.1.8",
|
||||
"is-svg": "4.2.2",
|
||||
"jszip": "^3.5.0",
|
||||
"mldoc": "0.7.0",
|
||||
"mldoc": "0.7.1",
|
||||
"path": "^0.12.7",
|
||||
"posthog-js": "^1.10.2",
|
||||
"react": "^17.0.2",
|
||||
|
|
|
@ -401,14 +401,33 @@
|
|||
(let [content (when content
|
||||
(let [content (text/remove-level-spaces content format)]
|
||||
(if (or (:pre-block? block)
|
||||
(= (:format block) :org)
|
||||
(src-block? block))
|
||||
(= (:format block) :org))
|
||||
content
|
||||
(remove-indentation-spaces content (:level block)))))]
|
||||
(if (= format :org)
|
||||
content
|
||||
(property/->new-properties content)))))
|
||||
|
||||
(defn- remove-indentations
|
||||
[format level element]
|
||||
(if (or (= level 1) (= format :org))
|
||||
element
|
||||
(case (first element)
|
||||
"Paragraph"
|
||||
["Paragraph"
|
||||
(let [level (if (= (ffirst (second element)) "Plain")
|
||||
(count (re-find #"^[\s\t]+" (second (first (second element)))))
|
||||
level)]
|
||||
(->> (partition-by #(= ["Break_Line"] %) (second element))
|
||||
(map (fn [c]
|
||||
(if (and (= (ffirst c) "Plain")
|
||||
(>= (count (re-find #"^[\s\t]+" (second (first c)))) level))
|
||||
(cons ["Plain" (subs (second (first c)) level)] (rest c))
|
||||
c)))
|
||||
(apply concat)))]
|
||||
|
||||
element)))
|
||||
|
||||
(defn extract-blocks
|
||||
[blocks content with-id? format]
|
||||
(let [encoded-content (utf8/encode content)
|
||||
|
@ -475,7 +494,9 @@
|
|||
|
||||
block (-> (assoc block
|
||||
:uuid id
|
||||
:body (vec (reverse block-body))
|
||||
:body (vec
|
||||
(->> (reverse block-body)
|
||||
(map #(remove-indentations format (:level block) %))))
|
||||
:properties (:properties properties)
|
||||
:refs ref-pages-in-properties
|
||||
:children (or current-block-children [])
|
||||
|
|
|
@ -3917,10 +3917,10 @@ mkdirp@^0.5.4, mkdirp@~0.5.1:
|
|||
dependencies:
|
||||
minimist "^1.2.5"
|
||||
|
||||
mldoc@0.7.0:
|
||||
version "0.7.0"
|
||||
resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-0.7.0.tgz#47bf1d324e098a1bc0b489df27fad54f16d23aea"
|
||||
integrity sha512-0V5Dt0VWSwOVXB93oISr8IY2BqVTPHzOkUYVW5WLNxH4v6YEiVan9aiJ4EPr5Nlzl/0+UoLOeHQhuePXf43bCA==
|
||||
mldoc@0.7.1:
|
||||
version "0.7.1"
|
||||
resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-0.7.1.tgz#315f4f288083f141d5d0ecba7d28af8e8e4a5435"
|
||||
integrity sha512-8eemlusips0cr+L7tYYFmjBo01A/Q1Al8kkXdnH6AnetajhnaSRje/i+kDBj4C4k7FRVdeTJJpiA+1EHqbLhJA==
|
||||
dependencies:
|
||||
yargs "^12.0.2"
|
||||
|
||||
|
|
Loading…
Reference in New Issue