Replace tagsoup dependency with enlive
Tagsoup depends on an old version of clojure.data.xml, which doesn't compile with clojure 1.9.0-alpha12. Enlive seems more actively maintained and used.
This commit is contained in:
parent
9c7c935d66
commit
dbd5caaf1f
3 changed files with 18 additions and 17 deletions
|
@ -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]])
|
||||
|
|
|
@ -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 "<!--more-->")]
|
||||
(if (pos? index)
|
||||
(let [s (subs content 0 index)]
|
||||
(->> ((tagsoup/parse-string s) 2)
|
||||
(drop 2)
|
||||
hiccup/html)))))
|
||||
"Returns the content until the <!--more--> special comment,
|
||||
closing any unclosed tags. Returns nil if there's no such comment."
|
||||
[content]
|
||||
(when-let [index (s/index-of content "<!--more-->")]
|
||||
(->> (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)
|
||||
(update post :content
|
||||
#(or (content-until-more-marker %)
|
||||
(->> (enlive/html-snippet %)
|
||||
(take blocks-per-preview)
|
||||
hiccup/html))}))
|
||||
enlive/emit*
|
||||
(apply str)))))
|
||||
|
||||
(defn create-previews
|
||||
"Returns a sequence of vectors, each containing a set of post previews"
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
and more content.
|
||||
</div>
|
||||
</div>")
|
||||
"<div id=\"post\"><div class=\"post-content\">
|
||||
"<div id=\"post\">
|
||||
<div class=\"post-content\">
|
||||
this post has more marker
|
||||
</div></div>")))
|
||||
|
||||
|
|
Loading…
Reference in a new issue