mirror of
https://github.com/logseq/logseq.git
synced 2026-04-30 00:46:23 +00:00
fix: Extra space and tab characters will be inserted into the file
close #2108 close #2057
This commit is contained in:
@@ -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 [])
|
||||
|
||||
Reference in New Issue
Block a user