diff --git a/project.clj b/project.clj index 5fd0ff8..c938571 100644 --- a/project.clj +++ b/project.clj @@ -14,6 +14,6 @@ [selmer "1.10.3"] [pandect "0.6.1"] [hawk "0.2.11"] - [clj-tagsoup "0.3.0" :exclusions [org.clojure/clojure]]] + [enlive "1.1.6"]] :deploy-repositories [["snapshots" :clojars] ["releases" :clojars]]) diff --git a/src/cryogen_core/compiler.clj b/src/cryogen_core/compiler.clj index e71bf2c..1b6d63c 100644 --- a/src/cryogen_core/compiler.clj +++ b/src/cryogen_core/compiler.clj @@ -5,8 +5,7 @@ [clojure.java.io :refer [copy file reader writer]] [clojure.string :as s] [text-decoration.core :refer :all] - [pl.danieljanus.tagsoup :as tagsoup] - [hiccup.core :as hiccup] + [net.cgrand.enlive-html :as enlive] [cryogen-core.toc :refer [generate-toc]] [cryogen-core.sass :as sass] [cryogen-core.markup :as m] @@ -295,23 +294,24 @@ :uri uri}))))) (defn content-until-more-marker - [^String content] - (let [index (.indexOf content "")] - (if (pos? index) - (let [s (subs content 0 index)] - (->> ((tagsoup/parse-string s) 2) - (drop 2) - hiccup/html))))) + "Returns the content until the special comment, + closing any unclosed tags. Returns nil if there's no such comment." + [content] + (when-let [index (s/index-of content "")] + (->> (subs content 0 index) + enlive/html-snippet + enlive/emit* + (apply str)))) (defn create-preview "Creates a single post preview" [blocks-per-preview post] - (merge post - {:content (or (content-until-more-marker (:content post)) - (->> ((tagsoup/parse-string (:content post)) 2) - (drop 2) - (take blocks-per-preview) - hiccup/html))})) + (update post :content + #(or (content-until-more-marker %) + (->> (enlive/html-snippet %) + (take blocks-per-preview) + enlive/emit* + (apply str))))) (defn create-previews "Returns a sequence of vectors, each containing a set of post previews" diff --git a/test/cryogen_core/compiler_test.clj b/test/cryogen_core/compiler_test.clj index 2d76c8d..46a5a55 100644 --- a/test/cryogen_core/compiler_test.clj +++ b/test/cryogen_core/compiler_test.clj @@ -22,7 +22,8 @@ and more content. ") - "