From b47c013b28fd36eb97c389ffe1948507eeef811b Mon Sep 17 00:00:00 2001 From: Christian Mueller Date: Tue, 8 Jul 2014 09:06:23 +0200 Subject: [PATCH] switched to PegDown directly --- project.clj | 2 +- resources/public/styles/main.less | 1 + src/notehub/handler.clj | 3 +-- src/notehub/views.clj | 16 +++++++++++----- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/project.clj b/project.clj index a6ea74f..082ef88 100644 --- a/project.clj +++ b/project.clj @@ -4,7 +4,7 @@ [org.clojure/core.cache "0.6.3"] [hiccup "1.0.0"] [zeus "0.1.0"] - [me.raynes/cegdown "0.1.1"] + [org.pegdown/pegdown "1.4.2"] [iokv "0.1.1"] [cheshire "5.3.1"] [ring/ring-core "1.2.0"] diff --git a/resources/public/styles/main.less b/resources/public/styles/main.less index c6fa783..e601680 100644 --- a/resources/public/styles/main.less +++ b/resources/public/styles/main.less @@ -170,6 +170,7 @@ h1, h2, h3, h4, h5, h6 { font-family: @header_font,'Noticia Text','PT Serif','Georgia'; } table { + width: 100%; border-collapse: collapse; } th { diff --git a/src/notehub/handler.clj b/src/notehub/handler.clj index 912a330..2df4ed3 100644 --- a/src/notehub/handler.clj +++ b/src/notehub/handler.clj @@ -6,7 +6,6 @@ [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] @@ -49,7 +48,7 @@ (defroutes app-routes (GET "/api" [] (layout :no-js (get-message :api-title) - [:article (md/to-html (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 0894060..40ba435 100644 --- a/src/notehub/views.clj +++ b/src/notehub/views.clj @@ -9,11 +9,17 @@ [hiccup.util :only [escape-html]] [hiccup.page :only [include-js html5]]) (:require - [me.raynes.cegdown :as md] - [notehub.api :as api])) + [notehub.api :as api]) + (:import (org.pegdown PegDownProcessor Extensions))) (def get-message (get-map "messages")) +(def md-processor + (PegDownProcessor. Extensions/TABLES)) + +(defn md-to-html [md-text] + (.markdownToHtml md-processor md-text)) + ; Creates the main html layout (defn layout [js? title & content] @@ -69,8 +75,8 @@ [:div#dashed-line] [:article.helvetica.bottom-space {:style "font-size: 1em"} - (md/to-html (slurp "LANDING.md"))] - [:div.centered.helvetica (md/to-html (get-message :footer))])) + (md-to-html (slurp "LANDING.md"))] + [:div.centered.helvetica (md-to-html (get-message :footer))])) (defn statistics-page [resp] @@ -104,7 +110,7 @@ (let [note (api/get-note {:noteID note-id}) sanitized-note (sanitize (:note note))] (layout :no-js (:title note) - [:article.bottom-space (md/to-html sanitized-note)] + [:article.bottom-space (md-to-html sanitized-note)] (let [urls {:short-url (api/url short-url) :notehub "/"} links (map #(link-to