ColorHighlighter
ColorHighlighter copied to clipboard
add support for color functions
I don't know how difficult this would be to implement but it would be amazing if the color functions for Stylus, Sass, etc. were supported.
@icylace Wow! That's not easy. I'll try.
You can do it! I believe in you!
Found this - may help with color functions. I'll play with it myself when I get some time.
https://github.com/Kronuz/pyScss
I've been thinking about this - there seem to be two viable options for implementing highlighting of color functions:
- Use Python functions to emulate Sass color functions, à la pyScss
- Run the Sass color function in the shell, returning the value to ColorHighlighter. Might be able to use/get inspiration from SassBeautify.
Option 2 seems easier to me. Hopefully it won't take too much to implement.
This would be awesome!
Also, I just saw this I wonder if you could steal some of the code here? https://atom.io/packages/atom-color-highlight
@garand Atom.io packages are Javascript, vs Sublime's Python, so this would require at least a rewrite/port across languages.
Gotcha. Anyways, just thought it was interesting. :smile:
This may be of some use as well: https://github.com/klen/python-scss
Been working on this a little today. @Monnoroch Is this the right logic flow for Sass vars in ColorHighlighter?
search lines in file for bound_symbols
look at Word after symbol
if Word begins with @ or $ it's Sass/Less
try name_to_hex against variable name
if Word matches a regex string in color_fmts_data
convert to 8char hex (#rrggbbff) for plugin use
So to implement Sass color function darken(color,amount), it would be necessary to write some new regex for color_fmts_data that would match darken(color,amount) and provide a helper to parse (run?) the function and convert to 8char hex?
Yes, this logic is correct. You could write your own mechanism for dealing with functions, but the simplest way is to list them all in color_fmts_data.
The problem here is that lots of regex matches creates this problem: https://github.com/Monnoroch/ColorHighlighter/issues/116 . There is a huge problem with performance already.
Since you here to write some code, maby you could think how to make this all faster.
+1 for this implementation
Another +1 for this. Great work, guys!
Please implement. +1 :D
This hasn't seem much activity since 2015 but I'd love to be able to see how my darken/lighten functions affect my base colour.