 
 (defn escape
   [text]
-  (clojure.string/replace
+  (string/replace
     text
-    (re-pattern (str "[" (clojure.string/join "" (keys replacements)) "]"))
+    (re-pattern (str "[" (string/join "" (keys replacements)) "]"))
     #(replacements %1)))
 
 (defn linkify
   [text]
-  (clojure.string/replace
+  (string/replace
     text
     #"(https?://[^\s]+)"
     "<a href=\"$1\">$1</a>"))


(defn get-classes
  [styles]
  (clojure.string/join " " (remove nil? (vals styles))))

(defn process-parts
  [styles [part & parts] done]
  (let [lines (clojure.string/split part "\n" -1)
        [_ codes text] (re-matches #"([\d;]+?)?m(.*)" (first lines))
        text           (str (or text (first lines))
                            (if (empty? (rest lines)) "" "\n")
                            (clojure.string/join "\n" (rest lines)))
        next-styles    (if (nil? codes)
                         {}
                         (apply merge (map (comp style int)
                                           (clojure.string/split codes ";"))))
        styles         (merge styles next-styles)
        classes        (get-classes styles)
        done           (if (empty? classes)

    (let [text (-> text
                   (escape)
                   (linkify))
          parts (string/split text #"\033\[")]
      (process-parts {} parts ""))))
