mirror of
https://github.com/logseq/logseq.git
synced 2026-05-23 20:24:15 +00:00
Left a few uses of gp-mldoc/default-config but only in file graph specific locations or functionality that wasn't related to db graphs e.g. handler. plugin. Also removed format/get-default-config as it was unused Part of LOG-2741
34 lines
958 B
Clojure
34 lines
958 B
Clojure
(ns frontend.format
|
|
"Main ns for providing common operations on file content like conversion to html
|
|
and edn. Can handle org-mode and markdown formats"
|
|
(:require [frontend.format.mldoc :refer [->MldocMode] :as mldoc]
|
|
[frontend.format.protocol :as protocol]
|
|
[logseq.graph-parser.mldoc :as gp-mldoc]
|
|
[logseq.graph-parser.util :as gp-util]
|
|
[clojure.string :as string]))
|
|
|
|
(defonce mldoc-record (->MldocMode))
|
|
|
|
(defn get-format-record
|
|
[format]
|
|
(case (gp-util/normalize-format format)
|
|
:org
|
|
mldoc-record
|
|
:markdown
|
|
mldoc-record
|
|
nil))
|
|
|
|
(defn to-html
|
|
[content format config]
|
|
(if (string/blank? content)
|
|
""
|
|
(if-let [record (get-format-record format)]
|
|
(protocol/toHtml record content config gp-mldoc/default-references)
|
|
content)))
|
|
|
|
(defn to-edn
|
|
[content format config]
|
|
(if-let [record (get-format-record format)]
|
|
(protocol/toEdn record content config)
|
|
nil))
|