add markup ns to abstract markdown vs asciidoc
This commit is contained in:
parent
0588dcae79
commit
68b82be959
1 changed files with 37 additions and 0 deletions
37
src/cryogen_core/markup.clj
Normal file
37
src/cryogen_core/markup.clj
Normal 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)])
|
Loading…
Reference in a new issue