Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blanklineBetweenSelectors has a failing case #37

Closed
owenleonard opened this issue Feb 12, 2014 · 5 comments
Closed

blanklineBetweenSelectors has a failing case #37

owenleonard opened this issue Feb 12, 2014 · 5 comments

Comments

@owenleonard
Copy link

When I run SassBeautify with blanklineBetweenSelectors set to true, the following:

.class-one,
.class-two,
.class-three {
    background-color: $aaa;
}

becomes:

.class-one,
.class-two,

.class-three {
    background-color: $aaa;
}

I found the regex code that deals with this

        # Insert a blank line between selectors. (Issue #30)
        if self.get_type() == 'scss' and self.settings.get('blanklineBetweenSelectors', False):
            output = re.sub(r'\n\n\n', '\n\n', re.sub(r'(.*)\{', r'\n\1{', output).strip())

This obviously requires the code to search back previous lines of scss until it finds the first one in the list. I'll keep thinking to see if I can come up with a solution. Might be easier to do this while the file is split up by line (where you're making sure the file uses unix-style newline characters).

By the way, I ran into this while trying to use SassBeautify in conjunction with SublimeLinter-contrib-scss-lint. It has a rule for a single selector per line. I'm finding that sass-convert isn't very compatible with scss-lint.

@badsyntax
Copy link
Owner

That regular expressions is flaky. To be honest I'm very tempted to remove this feature. I merged this feature in with pull request #30 without properly testing it. IMO the only reliable way of formatting code is to create a lexer/parser which is totally outside the scope of this plugin.

@badsyntax
Copy link
Owner

By the way, I ran into this while trying to use SassBeautify in conjunction with SublimeLinter-contrib-scss-lint. It has a rule for a single selector per line. I'm finding that sass-convert isn't very compatible with scss-lint.

Is the linter not configurable?

@owenleonard
Copy link
Author

It is configurable, but I'd rather make a beautifier/formatter match chosen
linting rules rather than the reverse. It may be that I need to write a
lexer/parser that can read in those linting rules and do the formatting
rather than relying on what sass-convert supplies...

On Thu, Feb 13, 2014 at 2:20 AM, Richard Willis notifications@github.comwrote:

By the way, I ran into this while trying to use SassBeautify in
conjunction with SublimeLinter-contrib-scss-lint. It has a rule for a
single selector per line. I'm finding that sass-convert isn't very
compatible with scss-lint.

Is the linter not configurable?

Reply to this email directly or view it on GitHubhttps://github.com//issues/37#issuecomment-34960776
.

@badsyntax
Copy link
Owner

I'd rather make a beautifier/formatter match chosen linting rules rather than the reverse

I agree. Really this plugin only provides the flexibility of sass-convert, which is not a lot! I have been thinking about providing post-sass-convert formatting features, but I'm still undecided. Perhaps there's a solid python sass lexer out there that I can use, but saying that it doesn't seem right to do it in python land, seeing as though sass already has a lexer/parser. If I was more familiar with ruby I would explore the option of creating a custom gem that uses sass but also provides additional formatting options.

@badsyntax
Copy link
Owner

I have decided to remove this feature entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants