mgreter/sass2scss

Url in a property value taken as a comment

Closed this issue · 1 comments

Perhaps due to recent changes, or not, but currently the following Sass:

@font-face
  font-family: 'Inder'
  font-style: normal
  font-weight: normal
  src: url('http://fonts/inder.eot?#iefix') format('embedded-opentype')

becomes SCSS:

@font-face {
  font-family: 'Inder';
  font-style: normal;
  font-weight: normal;
  src: url('http:; }//fonts/inder.eot?#iefix') format('embedded-opentype')

Without the // part seems to work as one would expect, valid SCSS.

Perhaps for the comment check, there should be added exclusion if the // is immediately after with :?

The correct way was to skip quoted strings in apostrophes completely (just had implemented this for double quotes so far). This would solve the issue you described above, but would still fail on:

src: url(http://fonts/inder.eot?#iefix)

.Therefore I've added your idea with the check for the colon before the source line comment opener too. But IMO the right approach here would be to count the brackets instead. Will take a look how difficult this would be to implement..

Update: Was actually pretty easy (dc50fd2) and should be more robust and I would guess that this is more in line with other css parsers. Question would be how ruby sass would treat something like this (sass2scss will recognize this as a source comment):

background: http://domain/img

Test cases can be found here mgreter/perl-libsass@1cf1aa4