Add mldoc integration test and start mldoc split

This commit is contained in:
Gabriel Horner
2022-05-05 20:44:56 -04:00
parent 77a4facbc7
commit 657bb09591
15 changed files with 171 additions and 86 deletions

View File

@@ -53,6 +53,7 @@
[promesa.core :as p]
[frontend.util.keycode :as keycode]
[logseq.graph-parser.util :as gp-util]
[logseq.graph-parser.mldoc :as gp-mldoc]
["path" :as path]))
;; FIXME: should support multiple images concurrently uploading
@@ -356,7 +357,7 @@
content (drawer/with-logbook block content)
content (with-timetracking block content)
first-block? (= left page)
ast (mldoc/->edn (string/trim content) (mldoc/default-config format))
ast (mldoc/->edn (string/trim content) (gp-mldoc/default-config format))
first-elem-type (first (ffirst ast))
first-elem-meta (second (ffirst ast))
properties? (contains? #{"Property_Drawer" "Properties"} first-elem-type)
@@ -1941,7 +1942,7 @@
props (into [] (:properties block))
content* (str (if (= :markdown format) "- " "* ")
(property/insert-properties format content props))
ast (mldoc/->edn content* (mldoc/default-config format))
ast (mldoc/->edn content* (gp-mldoc/default-config format))
blocks (block/extract-blocks ast content* true format)
fst-block (first blocks)]
(assert fst-block "fst-block shouldn't be nil")
@@ -2850,7 +2851,7 @@
(when-let [editing-block (state/get-edit-block)]
(let [page-id (:db/id (:block/page editing-block))
blocks (block/extract-blocks
(mldoc/->edn text (mldoc/default-config format)) text true format)
(mldoc/->edn text (gp-mldoc/default-config format)) text true format)
blocks' (block/with-parent-and-left page-id blocks)]
(paste-blocks blocks' {}))))
@@ -3168,7 +3169,7 @@
[format content semantic?]
(and (string/includes? content "\n")
(if semantic?
(let [ast (mldoc/->edn content (mldoc/default-config format))
(let [ast (mldoc/->edn content (gp-mldoc/default-config format))
first-elem-type (first (ffirst ast))]
(mldoc/block-with-title? first-elem-type))
true)))