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

Sorting inline stuff (html attributes, javascript object keys, css) #2

Open
3 of 4 tasks
Noitidart opened this issue Feb 4, 2017 · 6 comments
Open
3 of 4 tasks

Comments

@Noitidart
Copy link

Noitidart commented Feb 4, 2017

  • JSON
  • HTML attributes
  • CSS
  • JavaScript Objects

This is just such an awesome plugin. Thank you for it. I use it regularly to sort keys in javascript objects:

{z:true, b:false} => {b:false, z:true}

But I was hoping to use it on html attributes as well, but it splits on the = so it doesnt work. Is it possible to make it not split on =?

Like:

zid="body" key="body"

Should sort to:

key="body" zid="body"

Also some time in my js objects I have a space between the colon so like this:

{z: true, b: false}

And this fails to sort, is it possible to ignore the first space after a colon?

Example of inline css:

position: absolute; top: 1; bottom: 3;

A regex split that would work for this is /\:\w*/ or for equals sign: /\=\w*/

@Noitidart Noitidart changed the title Sorting html attributes Sorting inline stuff (html attributes, javascript object keys, css) Feb 4, 2017
FlorianWendelborn pushed a commit that referenced this issue Feb 5, 2017
@FlorianWendelborn
Copy link
Owner

FlorianWendelborn commented Feb 5, 2017

@Noitidart I'll look into it as I'm using this a lot too. I actually planned to (some day) implement an object-sorting mechanism that actually detects objects. I guess that'd fix part of this issue.

in my js objects I have a space between the colon

{z: true, b: false} => {b: false, z: true}

Works for me. What's the part you don't expect?

v0.1.3 should properly sort inline CSS. Let me know if there's anything unexpected happening.

FlorianWendelborn pushed a commit that referenced this issue Feb 5, 2017
@FlorianWendelborn
Copy link
Owner

v0.1.4 sorts b="B" a="A" to a="A" b="B"

FlorianWendelborn pushed a commit that referenced this issue Feb 5, 2017
@FlorianWendelborn
Copy link
Owner

v0.1.8 sorts style="top: 1px; bottom: 2px;" a="test" to a="test" style="top: 1px; bottom: 2px;"

@Noitidart
Copy link
Author

Noitidart commented Feb 5, 2017

Thank you sir so much!! You thought of common cases that I didn't even consider! Too great! :)

@FlorianWendelborn
Copy link
Owner

v1.0.0 should sort JSON properly. Doesn't work for plain objects though. :/

@Noitidart
Copy link
Author

Thank you sooo much for keeping us updated, especially the to do style task list you edited into the OP. JSON sorting is so awesome! Just tested it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants