diff --git a/project.clj b/project.clj index 194d447..a6ea74f 100644 --- a/project.clj +++ b/project.clj @@ -4,6 +4,7 @@ [org.clojure/core.cache "0.6.3"] [hiccup "1.0.0"] [zeus "0.1.0"] + [me.raynes/cegdown "0.1.1"] [iokv "0.1.1"] [cheshire "5.3.1"] [ring/ring-core "1.2.0"] diff --git a/resources/public/js/main.js b/resources/public/js/main.js index 84ae33f..7d8562c 100644 --- a/resources/public/js/main.js +++ b/resources/public/js/main.js @@ -39,14 +39,6 @@ function onLoad() { if(iosDetected) $note.className += " ui-border"; else $note.focus(); } - var mdDocs = document.getElementsByClassName("markdown"); - for(var i = 0; i < mdDocs.length; i++){ - var elem = mdDocs[i]; - var child = elem.childNodes[0]; - elem.innerHTML = md2html(child.value); - show(elem); - } - var links = $("links"); if(links){ if(window.innerHeight * 0.85 >= document.body.clientHeight) { diff --git a/resources/public/styles/main.less b/resources/public/styles/main.less index 3cbed7f..c6fa783 100644 --- a/resources/public/styles/main.less +++ b/resources/public/styles/main.less @@ -158,7 +158,7 @@ textarea { font-size: 1em; height: 500px; } -.hidden, .markdown, #links { +.hidden, #links { display: none; } #dashed-line { diff --git a/src/notehub/handler.clj b/src/notehub/handler.clj index 01c0ac5..6e27742 100644 --- a/src/notehub/handler.clj +++ b/src/notehub/handler.clj @@ -6,6 +6,7 @@ [clojure.string :rename {replace sreplace} :only [replace]] [clojure.core.incubator :only [-?>]]) (:require + [me.raynes.cegdown :as md] [clojure.core.cache :as cache] [hiccup.util :as util] [compojure.handler :as handler] @@ -48,7 +49,7 @@ (defroutes app-routes (GET "/api" [] (layout (get-message :api-title) - (md-node :article (slurp "API.md")))) + [:article (md/to-html (slurp "API.md"))])) (context "/api" [] #(ring.util.response/content-type (api-routes %) "application/json")) diff --git a/src/notehub/views.clj b/src/notehub/views.clj index 1c07139..406d374 100644 --- a/src/notehub/views.clj +++ b/src/notehub/views.clj @@ -9,6 +9,7 @@ [hiccup.util :only [escape-html]] [hiccup.page :only [include-js html5]]) (:require + [me.raynes.cegdown :as md] [notehub.api :as api])) (def get-message (get-map "messages")) @@ -32,14 +33,6 @@ (if-not (get-setting :dev-mode) (include-js "/js/google-analytics.js"))] [:body {:onload "onLoad()"} content])) -(defn md-node - "Returns an HTML element with a textarea inside - containing the markdown text (to keep all chars unescaped)" - ([cls input] (md-node cls {} input)) - ([cls opts input] - [(keyword (str (name cls) ".markdown")) opts - [:textarea input]])) - (defn- sanitize "Breakes all usages of