From df9f2b41405a570be26db9a2a89d0e4ee5396920 Mon Sep 17 00:00:00 2001 From: Nicolas Buduroi Date: Fri, 8 Apr 2011 05:15:46 +0800 Subject: [PATCH] Fixed HTML escaping issues and clean-up code. --- src/marginalia/html.clj | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/src/marginalia/html.clj b/src/marginalia/html.clj index 16529ef..b8aaebd 100644 --- a/src/marginalia/html.clj +++ b/src/marginalia/html.clj @@ -73,19 +73,6 @@ [s] (.markdown mdp s)) -(defn replace-special-chars - "Inserts super-fancy characters into the doc section." - [s] - (-> s - (str/replace #"->" "→") - (str/replace #""" "\""))) - -(defn replace-html-entities - [s] - (-> s - (str/replace "<" "<") - (str/replace ">" ">"))) - ;; As a result of docifying then grouping, you'll end up with a seq like this one: ;;
[...
 ;; {:docs [{:docs-text "Some doc text"}]
@@ -95,21 +82,6 @@
 ;; `docs-to-html` and `codes-to-html` convert their respective entries into html,
 ;; and `group-to-html` calls them on each seq item to do so.
 
-(defn prep-docs-text [s] s)
-
-(defn prep-docstring-text [s]
-  (-> s
-      (str/replace #"\\\"" "\"")
-      (str/replace #"^\s\s\"" "")
-      (str/replace #"^\s\s\s" "")
-      (str/replace #"\"$" "")
-      ;; Don't escape code blocks
-      ((fn [t]
-         (if (re-find #"^\s\s\s\s" t)
-           t
-           (escape-html t))))))
-
-
 (defn docs-to-html
   "Converts a docs section to html by threading each doc line through the forms
    outlined above.
@@ -121,14 +93,11 @@
   [docs]
   (-> docs
       str
-      prep-docs-text
-      replace-special-chars
-      replace-html-entities
       (md)))
 
 (defn codes-to-html [code-block]
   (html [:pre {:class "brush: clojure"}
-         (replace-html-entities code-block)]))
+         (escape-html code-block)]))
 
 (defn section-to-html [section]
   (html [:tr