-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Remove , (comm) from edn #130
Comments
I've written a script once to remove commas: borkdude@m1 ~/dev/babashka (master*) $ echo '{:a 1 :b 2}' | jet
{:a 1, :b 2}
borkdude@m1 ~/dev/babashka (master*) $ echo '{:a 1 :b 2}' | jet | /tmp/strip_commas.bb
{:a 1 :b 2}
borkdude@m1 ~/dev/babashka (master*) $ cat /tmp/strip_commas.bb
#!/usr/bin/env bb
(require '[rewrite-clj.zip :as z])
(-> (let [loc (z/of-string (slurp *in*))]
(loop [loc loc]
(let [next (z/next* loc)]
(if (z/end? loc) (z/root loc)
(if (= :comma (z/tag loc))
(recur (z/remove* loc))
(recur next))))))
str
(print))
(flush) We could integrate this into jet, but I'll wait for more upvotes first. |
Looks like a good code to be behind a flag to |
Why would you do this by default? |
Wow, where do all these upvotes come from, was there a campaign within nubank? :) Please explain more why this feature is considered important. |
All the time I'd prefer to see a edn without commas, I suppose most people as well, but we could gather more feedback about that. @borkdude we usually code edn without commas, like: {:a 1
:b 2
:c 3} And we use jet/jet.el to parse json<->edn to paste on code, and it's kind of inconvenient the need to keep removing commas after parsing it as we don't write: {:a 1,
:b 2,
:c 3} |
Alright. I'll hopefully get to it this week! :) |
@ericdallo @leandropincini Is this mostly about commas between map entries? The library I'm using to colorize (puget) only allows stripping the comma between map entries, not generally. So what I could do: If |
IMO stripping all commas is a better choice, what we want most if not all the time, otherwise would be |
I know that's better but it's not possible in combination with colorization at the moment, unless I implement my own colorization. |
Anyway, in emacs when calling jet, it won't produce colorized output anyway and then all commas would be removed. |
I was wondering if it worths to add a know issue (breaks the color) for that and some ways to avoid it. |
Published as 0.5.25 and the option is called |
I'm wondering if maybe we could have a feature that removes the
,
(comm) while parsing to edn.Like parse a json -> edn without commas.
Clojurian's slack thread: https://clojurians.slack.com/archives/CM5HRADAA/p1682017322255449
The text was updated successfully, but these errors were encountered: