Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utility function to remove whitespace from hiccup forms #28

Open
lvh opened this issue Sep 22, 2015 · 3 comments
Open

Utility function to remove whitespace from hiccup forms #28

lvh opened this issue Sep 22, 2015 · 3 comments
Labels
category: ergonomics Quality of Life improvements good first issue People will gladly help if you make it easy type: feature request Feature requests

Comments

@lvh
Copy link

lvh commented Sep 22, 2015

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.)

@davidsantiago
Copy link
Collaborator

I think you've misdirected this... :)

@lvh
Copy link
Author

lvh commented Sep 23, 2015

What do you mean? I meant to suggest it for inclusion in Hickory; when using Hickory I often end up with Hiccup-format data structures that have a bunch of boring whitespace in them.

@davidsantiago
Copy link
Collaborator

Ah, your message made me think you were trying to get this into Hiccup. I suppose if this is useful it could fit in convert.cljx. Should also have some tests to go with it.

@port19x port19x added type: feature request Feature requests good first issue People will gladly help if you make it easy priority 4: wishlist category: ergonomics Quality of Life improvements and removed priority 4: wishlist labels Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: ergonomics Quality of Life improvements good first issue People will gladly help if you make it easy type: feature request Feature requests
Projects
None yet
Development

No branches or pull requests

3 participants