21 lines
794 B
Clojure
21 lines
794 B
Clojure
(ns clojure.string)
|
|
|
|
;; NOTE NOTE NOTE! This is not the real `clojure.string`. It dummies enough
|
|
;; of `clojure.string` to get other libraries I'm using running!
|
|
|
|
(defn escape
|
|
"Escape characters in `s` which HTML cannot be certain to directly render,
|
|
using hints from these `char-escapes`, which is expected to map characters
|
|
to string representations of appropriate HTML entity substutions."
|
|
[s char-escapes]
|
|
(apply str (map #(let [c (int %)
|
|
m (char-escapes %)]
|
|
(cond m m
|
|
(<= 32 c 126) %
|
|
:else (str "&#" c ";"))) s)))
|
|
|
|
(defn replace
|
|
"Replace all occurences of this `pattern` in this string `s` with this `replace`ment."
|
|
[s pattern replace]
|
|
(.replaceAll s pattern replace))
|