|
|
@@ -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 [])
|