CSS url() with no quotes highlights incorrectly #1026

Closed
xeenon opened this Issue Dec 1, 2012 · 6 comments

Comments

Projects
None yet
3 participants
Contributor

xeenon commented Dec 1, 2012

.test {
    background: url(example.png#foo);
    background: url( exam\)ple.png#foo);
    background: url(exam\'ple.png#foo );
}

Expected: the contents between () should be tokenize as "string" or "link".

From the spec:

The format of a URI value is 'url(' followed by optional white space followed by an optional single quote (') or double quote (") character followed by the URI itself, followed by an optional single quote (') or double quote (") character followed by optional white space followed by ')'. The two quote characters must be the same.

http://www.w3.org/TR/CSS21/syndata.html#uri

@peterkroon peterkroon added a commit to peterkroon/CodeMirror2 that referenced this issue Dec 1, 2012

@peterkroon peterkroon Update mode/less/less.js ef6211a

@peterkroon peterkroon added a commit to peterkroon/CodeMirror2 that referenced this issue Dec 1, 2012

@peterkroon peterkroon Update mode/less/less.js 6ee66bd

marijnh closed this in e2e78fe Dec 3, 2012

@marijnh marijnh added a commit that referenced this issue Dec 3, 2012

@marijnh marijnh [css mode] Handle unquoted url(...) values
Closes #1026
de88672
Contributor

xeenon commented Dec 3, 2012

Thanks! Does this eat the optional whitespace inside the parenthesis?

Owner

marijnh commented Dec 3, 2012

How about you try?

Contributor

xeenon commented Dec 3, 2012

Touché!

It does eat leading space but not trailing space. Here is the example in the Web Inspector:

http://timothy.hatcher.name/css-url-spaces.png

Owner

marijnh commented Dec 4, 2012

Ah, I see what you mean. Is that important? For quoted strings, the string markup will span only the quoted parts. For non-quoted ones, it'll span everything between the parens. Kind of makes sense, no?

Contributor

peterkroon commented Dec 4, 2012

I've got this covered in the new LESS/SCSS mode/theme.
Right now , I'm trying to make this work with css only as well (Work in progress....).
Look here: http://5060.nl/codemirror/CodeMirror-3/mode/less/index.html
Line 227

Contributor

xeenon commented Dec 4, 2012

Well I would expect both prefix and postfix spaces to be included in the string style — not just the postfix spaces as it is now. But ideally no prefix or postfix spaces would be included since those are not part of the URL that the browser uses to load the resource.

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