Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions SassBeautify.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ def beautify_newlines(self, content):
def insert_newline_between_capturing_parentheses(m):
return m.group(1) + '\n' + m.group(2)

def remove_extra_line_before_closing_bracket(m):
return m.group(1) + m.group(3)

# Insert newline after "}" or ";" if the line after defines (or starts to define) a selector
# (i.e. contains some characters followed by a "{" or "," on the same line).
# This is in order to make the selector more visible and increase readability
Expand All @@ -172,8 +175,11 @@ def insert_newline_between_capturing_parentheses(m):
# Similar to above, except the next line is a commented out line followed by a selector
content = re.sub(re.compile('(;.*|}.*)(\n +//.*\n.+[{,])$', re.MULTILINE), insert_newline_between_capturing_parentheses, content)

# clean up new lines added after an end of line comment and before a }
content = re.sub(re.compile(r'(//.*\n)([ \t]*\n)([ \t]*})', re.MULTILINE), remove_extra_line_before_closing_bracket, content)

return content

def use_single_quotes(self, content):
content = content.replace('"', '\'')
return content
Expand Down Expand Up @@ -229,7 +235,7 @@ def handle_process(self, returncode, output, error):

if self.settings.get('newlineBetweenSelectors', False):
output = self.beautify_newlines(output)

if self.settings.get('useSingleQuotes', False):
output = self.use_single_quotes(output)

Expand Down