fix: Disable mixed heading in unordered list for now

This commit is contained in:
Tienson Qin
2021-04-29 20:58:15 +08:00
parent 99d7ad04a3
commit f2dffd51fa
5 changed files with 28 additions and 13 deletions

View File

@@ -275,17 +275,26 @@
block))
(defn- wrap-parse-block
[{:block/keys [content format] :as block}]
[{:block/keys [content format parent page] :as block}]
(let [ast (mldoc/->edn (string/trim content) (mldoc/default-config format))
first-elem-type (first (ffirst ast))
properties? (= "Properties" first-elem-type)
top-level? (= parent page)
markdown-heading? (and (= format :markdown)
(= "Heading" first-elem-type))
heading? (= "Paragraph" first-elem-type)
content (string/triml content)
content' (if (or properties? markdown-heading?)
content
(str (config/get-block-pattern format) (if heading? " " "\n") content))
[content content'] (cond
(or properties? (and markdown-heading? top-level?))
[content content]
markdown-heading?
(let [content (string/replace content #"^#+\s+" "")]
[content (str (config/get-block-pattern format) " " content)])
:else
(let [content' (str (config/get-block-pattern format) (if heading? " " "\n") content)]
[content content']))
block (block/parse-block (assoc block :block/content content'))
block (attach-page-properties-if-exists! block)]
(-> block