 (programs pygmentize)
 
 (def ^:dynamic *plain* true)
+
+(defn basic-html-escape
+  [data]
+  (clojure.string/escape data { \< "&lt;" \> "&gt;" \& "&amp;" \" "&quot;" }))
 
 (defn adjust-facts-code [s spaces]
   (let [i-arrow (.lastIndexOf s "=>")]

    :ns
    [:div
     (if *plain*
       [:pre (:content elem)]
       (pygmentize  "-f" "html" "-l" (or (:lang elem) "clojure")
                    {:in (:content elem)}))]
    :code

       [:h4 [:i (str "e." (:num elem)
                     (if-let [t (:title elem)] (str "  &nbsp;-&nbsp; " t)))]])
     (if *plain*
       [:pre (-> (:content elem)
                 (basic-html-escape)
                 (adjust-indented-code (apply str (repeat (or (:fact-level elem) 0) "  "))))]
       (pygmentize  "-f" "html" "-l" (or (:lang elem) "clojure")
                   {:in (adjust-indented-code (:content elem)
                                              (apply str (repeat (or (:fact-level elem) 0) "  ")))}))]))
