Merge pull request #5265 from logseq/enhance/graph-parser-part-two

Enhance: Migrate mldoc and text to graph-parser
This commit is contained in:
Tienson Qin
2022-05-12 20:22:51 +08:00
committed by GitHub
46 changed files with 618 additions and 482 deletions

View File

@@ -2,6 +2,7 @@
(:require [clojure.string :as string]
[frontend.util :as util]
[logseq.graph-parser.util :as gp-util]
[logseq.graph-parser.mldoc :as gp-mldoc]
[frontend.util.property :as property]
[frontend.format.mldoc :as mldoc]))
@@ -23,7 +24,7 @@
(defn get-drawer-ast
[format content typ]
(let [ast (mldoc/->edn content (mldoc/default-config format))
(let [ast (mldoc/->edn content (gp-mldoc/default-config format))
typ-drawer (ffirst (filter (fn [x]
(mldoc/typ-drawer? x typ)) ast))]
typ-drawer))
@@ -32,7 +33,7 @@
[format content typ value]
(when (string? content)
(try
(let [ast (mldoc/->edn content (mldoc/default-config format))
(let [ast (mldoc/->edn content (gp-mldoc/default-config format))
has-properties? (some (fn [x] (mldoc/properties? x)) ast)
has-typ-drawer? (some (fn [x] (mldoc/typ-drawer? x typ)) ast)
lines (string/split-lines content)

View File

@@ -5,8 +5,9 @@
[frontend.config :as config]
[medley.core :as medley]
[logseq.graph-parser.util :as gp-util]
[logseq.graph-parser.mldoc :as gp-mldoc]
[frontend.format.mldoc :as mldoc]
[frontend.text :as text]
[logseq.graph-parser.text :as text]
[frontend.util.cursor :as cursor]))
(defonce properties-start ":PROPERTIES:")
@@ -187,7 +188,7 @@
properties (filter (fn [[k _v]] ((built-in-properties) k)) properties)]
(if (seq properties)
(let [lines (string/split-lines content)
ast (mldoc/->edn content (mldoc/default-config format))
ast (mldoc/->edn content (gp-mldoc/default-config format))
[title body] (if (mldoc/block-with-title? (first (ffirst ast)))
[(first lines) (rest lines)]
[nil lines])
@@ -233,7 +234,7 @@
(insert-property format content key value false))
([format content key value front-matter?]
(when (string? content)
(let [ast (mldoc/->edn content (mldoc/default-config format))
(let [ast (mldoc/->edn content (gp-mldoc/default-config format))
title? (mldoc/block-with-title? (ffirst (map first ast)))
has-properties? (or (and title?
(or (mldoc/properties? (second ast))

View File

@@ -4,7 +4,7 @@
[frontend.util.property :as property-util]
[frontend.util.cursor :as cursor]
[frontend.config :as config]
[frontend.text :as text]
[logseq.graph-parser.text :as text]
[cljs.reader :as reader]
[goog.object :as gobj]))