-
Notifications
You must be signed in to change notification settings - Fork 48
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
(->snake_case :s3-key) ; => :s_3_key #22
Comments
This is quite tricky to solve correctly in the general case without first classifying the case of the input string. I've thought about it before but will look into it again this weekend. If you want to take a stab at it yourself, take a look at this expression: https://github.com/qerub/camel-snake-kebab/blob/master/src/camel_snake_kebab/internals/misc.cljx#L29 |
Yes, it does seem like quite a tricky problem. The only thing I could think of was never adding split points when going from snake case to kebab case and vice versa, but this would mean conversions to and from camelcase would no longer be reversible, which doesn't sound ideal. Will have a ponder too. |
The way I solved this in lettercase was to optionally allow the user to pass in their own separator regex. In your case, it would be camel-snake-kebab has diverged a bunch from when we were similar in order to support CLJS, so enabling that is a bit tricky. I think one way you could do this is to enable you to pass the separators to Since you can't use a regex, perhaps better would be to name the split rules (ex. |
Yeah, this makes sense and can be viewed as a sort of manual classification of the input case. I'll give this approach a try in this shape: (->snake_case ident :splitter \-)
(->CamelCase ident :splitter #"\s+") An alternative I can think of is automatic classification based on the presence of certain chars (i.e. presence of Another alternative would be to let the user state the expected input type (e.g.
I can use regexes for simple char splits, just not for case shifts. |
I've created pull request #23 implementing the previously mentioned approach. Feedback is more than welcome. |
The just released version 0.3.0 allows you to do I'm leaving this issue open because I want a better solution. |
There's a similar annoying problem with kebab-case" (csk/->kebab-case :s3_bucket_name)
;; > :s-3-bucket-name |
Is there any update on this issue? I mean it's been hanging here since 2014 😱 |
Yeah, I'd also very much like a way to disable letters followed by numbers being separated. |
A reminder that snake -> kebabs transforms containing non-leading numbers are not reversible: (-> "a1_example"
->kebab-case-keyword
->snake_case_string)
"a_1_example"
(-> "a2a_example"
->kebab-case-keyword
->snake_case_string)
"a_2a_example" |
Is there any way to avoid numbers creating separators? Had a quick scan of the code but couldn't see an obvious workaround. Thanks.
The text was updated successfully, but these errors were encountered: