add markup ns to abstract markdown vs asciidoc

This commit is contained in:
Adam Tankanow 2014-12-29 11:15:48 -05:00
parent 0588dcae79
commit 68b82be959

View file

@ -0,0 +1,37 @@
(ns cryogen-core.markup
(:require [markdown.core :refer [md-to-html-string]]
[clojure.string :as s])
(:import org.asciidoctor.Asciidoctor$Factory
java.util.Collections))
(defprotocol Markup
(dir [this])
(ext [this])
(render-fn [this]))
(defn- markdown []
(reify Markup
(dir [this] "md")
(ext [this] ".md")
(render-fn [this]
(fn [rdr]
(md-to-html-string
(->> (java.io.BufferedReader. rdr)
(line-seq)
(s/join "\n"))
:heading-anchors true)))))
(defn- asciidoc []
(reify Markup
(dir [this] "asc")
(ext [this] ".asc")
(render-fn [this]
(fn [rdr]
(.convert (Asciidoctor$Factory/create)
(->> (java.io.BufferedReader. rdr)
(line-seq)
(s/join "\n"))
(Collections/emptyMap))))))
(defn markups []
[(markdown) (asciidoc)])