Skip to content
Browse files

Parse out some of the markdown in the examples when returned.

Hopefully this makes it a bit more human-readable until we figure out
a better solution for storing examples.
  • Loading branch information...
1 parent cb51fc8 commit 3940fa9a5a433e3513a4492378884ba9ef8233c5 @dakrone dakrone committed Sep 14, 2010
Showing with 22 additions and 3 deletions.
  1. +2 −1 project.clj
  2. +20 −2 src/cd_client/core.clj
View
3 project.clj
@@ -3,4 +3,5 @@
:dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]
[clj-http "0.1.1"]
- [org.danlarkin/clojure-json "1.1"]])
+ [org.danlarkin/clojure-json "1.1"]]
+ :dev-dependencies [[swank-clojure "1.2.1"]])
View
22 src/cd_client/core.clj
@@ -13,10 +13,27 @@
(def *seealso-api* (str *clojuredocs-root* "/see-also/"))
+(defn format-examples
+ [examples]
+ (map (fn
+ [ex]
+ (let [body (:body ex)]
+ (assoc ex :body (-> body
+ (.replaceAll "<pre>" "")
+ (.replaceAll "</pre>" "")
+ (.replaceAll "<p>" "")
+ (.replaceAll "</p>" "")
+ (.replaceAll "&gt;" ">")
+ (.replaceAll "<br>" "")
+ (.replaceAll "<br/>" "")
+ (.replaceAll "<br />" "")
+ (.replaceAll "\\\\r\\\\n" "\\\\n"))))) examples))
+
+
(defn examples
"Return examples for a given namespace and method name."
[ns name]
- (json/decode-from-str (:body (http/get (str *examples-api* ns "/" name)))))
+ (format-examples (json/decode-from-str (:body (http/get (str *examples-api* ns "/" name))))))
(defn search
@@ -30,7 +47,8 @@
(defn comments
"Return comments for a given namespace and method name."
[ns name]
- (json/decode-from-str (:body (http/get (str *comments-api* ns "/" name)))))
+ (format-examples
+ (json/decode-from-str (:body (http/get (str *comments-api* ns "/" name))))))
(defn see-also

0 comments on commit 3940fa9

Please sign in to comment.
Something went wrong with that request. Please try again.