diff --git a/project.clj b/project.clj
index 6880f6a..9401572 100644
--- a/project.clj
+++ b/project.clj
@@ -1,4 +1,4 @@
-(defproject cryogen-core "0.1.15"
+(defproject cryogen-core "0.1.16"
:description "Cryogen's compiler"
:url "https://github.com/lacarmen/cryogen-core"
:license {:name "Eclipse Public License"
@@ -12,6 +12,4 @@
[io.aviso/pretty "0.1.13"]
[hiccup "1.0.5"]
[selmer "0.7.8"]
- [markdown-clj "0.9.62"]
- [pandect "0.4.1"]
- [org.asciidoctor/asciidoctorj "1.5.2"]])
+ [pandect "0.4.1"]])
diff --git a/src/cryogen_core/markup.clj b/src/cryogen_core/markup.clj
index 71b7b41..2162b15 100644
--- a/src/cryogen_core/markup.clj
+++ b/src/cryogen_core/markup.clj
@@ -1,9 +1,7 @@
(ns cryogen-core.markup
- (:require [markdown.core :refer [md-to-html-string]]
- [markdown.transformers :refer [transformer-vector]]
- [clojure.string :as s])
- (:import org.asciidoctor.Asciidoctor$Factory
- java.util.Collections))
+ (:import java.util.Collections))
+
+(defonce markup-registry (atom []))
(defprotocol Markup
"A markup engine comprising a dir(ectory) containing markup files,
@@ -13,56 +11,16 @@
(ext [this])
(render-fn [this]))
-(defn- rewrite-hrefs
+(defn rewrite-hrefs
"Injects the blog prefix in front of any local links
ex. becomes "
[blog-prefix text]
(clojure.string/replace text #"href=.?/|src=.?/" #(str (subs % 0 (dec (count %))) blog-prefix "/")))
-(defn- rewrite-hrefs-transformer
- "A :replacement-transformer for use in markdown.core that will inject the
- given blog prefix in front of local links."
- [{:keys [blog-prefix]} text state]
- [(rewrite-hrefs blog-prefix text) state])
-
-(defn- markdown
- "Returns a Markdown (https://daringfireball.net/projects/markdown/)
- implementation of the Markup protocol."
- []
- (reify Markup
- (dir [this] "md")
- (ext [this] ".md")
- (render-fn [this]
- (fn [rdr config]
- (md-to-html-string
- (->> (java.io.BufferedReader. rdr)
- (line-seq)
- (s/join "\n"))
- :reference-links? true
- :heading-anchors true
- :replacement-transformers (conj transformer-vector (partial rewrite-hrefs-transformer config)))))))
-
-(defn- asciidoc
- "Returns an Asciidoc (http://asciidoc.org/) implementation of the
- Markup protocol."
- []
- (reify Markup
- (dir [this] "asc")
- (ext [this] ".asc")
- (render-fn [this]
- (fn [rdr config]
- (->>
- (.convert (Asciidoctor$Factory/create)
- (->> (java.io.BufferedReader. rdr)
- (line-seq)
- (s/join "\n"))
- (Collections/emptyMap))
- (rewrite-hrefs (:blog-prefix config)))))))
-
(defn markups
"Return a vector of Markup implementations. This is the primary entry point
for a client of this ns. This vector should be used to iterate over supported
Markups."
[]
- [(markdown) (asciidoc)])
+ @markup-registry)
diff --git a/src/cryogen_core/plugins.clj b/src/cryogen_core/plugins.clj
new file mode 100644
index 0000000..35f6a7c
--- /dev/null
+++ b/src/cryogen_core/plugins.clj
@@ -0,0 +1,16 @@
+(ns cryogen-core.plugins
+ (:require [cryogen-core.compiler :refer [compile-assets-timed]]
+ [clojure.edn :as edn]
+ [text-decoration.core :refer :all]))
+
+(defn load-plugin [url]
+ (let [config (edn/read-string (slurp url))]
+ (println (green (str "loading module: " (:description config))))
+ (require (:namespace config))))
+
+(defn load-plugins []
+ (let [plugins (.getResources (ClassLoader/getSystemClassLoader) "plugin.edn")]
+ (loop []
+ (load-plugin (.. plugins nextElement openStream))
+ (when (.hasMoreElements plugins)
+ (recur)))))