None of this is working very well; bit it is working a bit.

This commit is contained in:
Simon Brooke 2025-08-30 08:53:37 +01:00
parent 3551623374
commit 357d4c5853
7 changed files with 2518 additions and 2 deletions

View file

@ -0,0 +1,20 @@
(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))