chrisbra / Colorizer

color hex codes and color names
550 stars 31 forks source link

Some rgba colors are not highlighted #27

Closed bartels closed 11 years ago

bartels commented 11 years ago

This works fine: rgba(255, 255, 0, 0.7)

Without the leading zero for the alpha value, we get no color highlighting: rgba(255, 255, 0, .7)

Looks like a quick fix to make the leading zero optional in the regex on line 1112:

\ 'rgba': ['rgba(\s*\%(\d\+%\?\D*\)\{3}\%(\%(0\?\%(.\d\+\)\?\)\|1\))', function("s:ColorRGBValues")],
chrisbra commented 11 years ago

On Thu, November 14, 2013 22:49, Eric Bartels wrote:

This works fine: rgba(255, 255, 0, 0.7)

Without the leading zero for the alpha value, we get no color highlighting: rgba(255, 255, 0, .7)

Looks like a quick fix to make the leading zero optional in the regex on line 1112:

\ 'rgba': ['rgba(\s*\%(\d\+%\?\D*\)\{3}\%(\%(0?\%(.\d\+\)\?\)\|1\))',

function("s:ColorRGBValues")],

Yes, that would probably work (besides, that it should be 0\?.

But this doesn't seem to be supported by the standard, is it?

Best, Christian

bartels commented 11 years ago

Ah, yes thanks for catching the typo. it should be 0\?

Yeah, I was not totally sure if it's part of the standard. Browsers support it. I do see that format used pretty frequently, for example in the Bootstrap source code. I found this

Quote:

A can either be an , or it can be zero or more digits followed by a dot (.) followed by one or more digits.

It seems to suggest the initial digit before the dot is optional.

Thanks for the great plugin!

chrisbra commented 11 years ago

Hi Eric!

On Do, 14 Nov 2013, Eric Bartels wrote:

Ah, yes thanks for catching the typo. it should be 0\?

Yeah, I was not totally sure if it's part of the standard. Browsers support it. I do see that format used pretty frequently, for example in the Bootstrap source code. I found this

Quote:

A can either be an , or it can be zero or more digits followed by a dot (.) followed by one or more digits.

It seems to suggest the initial digit before the dot is optional.

Thanks for the great plugin!

This should be fixed by now. Please confirm.

Best,

Christian

Und nimmer kann ein Mensch, wie sehr er sich vermißt, Im Auge andrer Leute sein, was er nicht ist. -- Nicolas Boileau-Despréaux (Satiren)

bartels commented 11 years ago

Yes, that seems to do it. Thanks.

Btw, looks like some merge conflict cruft made its way into the latest commit: https://github.com/chrisbra/color_highlight/commit/0f346052ffe032e09ff9fb8992ea8e891afa5e02#diff-fed2dd0c6e6cf9ea53a80bf24675c546R54

chrisbra commented 11 years ago

Thanks, I removed them.