Files
logseq/src/main/frontend/format.cljs
Gabriel Horner 3f773ed876 fix: update all db graph uses of mldoc to use db config
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
2023-10-27 14:08:55 -04:00

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))