Open
Description
Hi!
This seems like a fairly reasonable utility feature that I've needed in more than one place now.
(def ^:private whitespace?
"Is this a string, and does it consist of only whitespace?"
(every-pred string? (partial re-matches #"\s*")))
(defn ^:private remove-whitespace
"Walk a given Hiccup form and remove all pure whitespace."
[row]
(walk/prewalk
(fn [form]
(if (vector? form)
(into [] (remove whitespace? form))
form))
row))
(walk
is [clojure.walk :as walk]
.)
If you'd like it in Hiccup, I'm more than happy to add it (with unit tests, of course.)