adamschwartz / log

Console.log with style.
https://adamschwartz.co/log
MIT License
3.01k stars 139 forks source link

Set color via single quotes #11

Closed artemeff closed 11 years ago

artemeff commented 11 years ago
log("this is [c='color: red']red[c]")
# for easy debugging with coffee
log "this is [c='color: red']#{someVariable}[c]"
craniumslows commented 11 years ago

I got to use back references :) :+1: c\=([\"\'])(._)\1[c] the \1 matches the opening " or ' so it is still just 1 function

adamschwartz commented 11 years ago

@craniumslows Thanks for the PR. But I'm starting to think perhaps we should forgo quotes altogether?

log "this is [c=color: red]#{someVariable}[c]"

Anyone forsee any issues with this? I think actually it's probably better since it simplifies the issue of allowing quotes in a url() delcaration:

log 'this is a [c=background-image: url("house.png"); text-indent: -999px]house[c]'

If it's possible to support ", ', and no quotes with a regex which does not degrade performance, I think we should support all three. Otherwise, I think we should support no quotes only and deprecate the old syntax. @artemeff @craniumslows Thoughts?

craniumslows commented 11 years ago

I think it wouldn't be too hard to summon appropriate regex. Good idea about the URLs.

craniumslows commented 11 years ago

Alrighty accepts no quotes or quotes. My PR if accepted should close out issues 10,11 and 12