| | |
| | | "@supports": true, |
| | | "@document": true |
| | | }; |
| | | this.NON_SEMICOLON_NEWLINE_PROPERTY = [ |
| | | "grid-template" |
| | | ]; |
| | | |
| | | } |
| | | |
| | |
| | | var enteringConditionalGroup = false; |
| | | var insideAtExtend = false; |
| | | var insideAtImport = false; |
| | | var insideScssMap = false; |
| | | var topCharacter = this._ch; |
| | | var insideNonSemiColonValues = false; |
| | | var whitespace; |
| | | var isAfterSpace; |
| | | var previous_ch; |
| | |
| | | |
| | | // Ensures any new lines following the comment are preserved |
| | | this.eatWhitespace(true); |
| | | } else if (this._ch === '@') { |
| | | } else if (this._ch === '@' || this._ch === '$') { |
| | | this.preserveSingleSpace(isAfterSpace); |
| | | |
| | | // deal with less propery mixins @{...} |
| | |
| | | this.indent(); |
| | | this._output.set_indent(this._indentLevel); |
| | | } else { |
| | | this.indent(); |
| | | // inside mixin and first param is object |
| | | if (previous_ch === '(') { |
| | | this._output.space_before_token = false; |
| | | } else if (previous_ch !== ',') { |
| | | this.indent(); |
| | | } |
| | | this.print_string(this._ch); |
| | | } |
| | | |
| | |
| | | this._output.add_new_line(true); |
| | | } |
| | | } |
| | | if (this._input.peek() === ')') { |
| | | this._output.trim(true); |
| | | if (this._options.brace_style === "expand") { |
| | | this._output.add_new_line(true); |
| | | } |
| | | } |
| | | } else if (this._ch === ":") { |
| | | |
| | | for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) { |
| | | if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) { |
| | | insideNonSemiColonValues = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) { |
| | | // 'property: value' delimiter |
| | | // which could be in a conditional group query |
| | |
| | | this.print_string(this._ch + this.eatString(this._ch)); |
| | | this.eatWhitespace(true); |
| | | } else if (this._ch === ';') { |
| | | insideNonSemiColonValues = false; |
| | | if (parenLevel === 0) { |
| | | if (insidePropertyValue) { |
| | | this.outdent(); |
| | |
| | | } else { |
| | | this.preserveSingleSpace(isAfterSpace); |
| | | this.print_string(this._ch); |
| | | this.eatWhitespace(); |
| | | parenLevel++; |
| | | this.indent(); |
| | | |
| | | // handle scss/sass map |
| | | if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) { |
| | | this._output.add_new_line(); |
| | | insideScssMap = true; |
| | | } else { |
| | | this.eatWhitespace(); |
| | | parenLevel++; |
| | | this.indent(); |
| | | } |
| | | } |
| | | } else if (this._ch === ')') { |
| | | if (parenLevel) { |
| | | parenLevel--; |
| | | this.outdent(); |
| | | } |
| | | if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) { |
| | | insideScssMap = false; |
| | | this.outdent(); |
| | | this._output.add_new_line(); |
| | | } |
| | | this.print_string(this._ch); |
| | | } else if (this._ch === ',') { |
| | | this.print_string(this._ch); |
| | | this.eatWhitespace(true); |
| | | if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport && !insideAtExtend) { |
| | | if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideAtImport && !insideAtExtend) { |
| | | this._output.add_new_line(); |
| | | } else { |
| | | this._output.space_before_token = true; |
| | |
| | | this.print_string(' '); |
| | | this.print_string(this._ch); |
| | | } else { |
| | | this.preserveSingleSpace(isAfterSpace); |
| | | var preserveAfterSpace = previous_ch === '"' || previous_ch === '\''; |
| | | this.preserveSingleSpace(preserveAfterSpace || isAfterSpace); |
| | | this.print_string(this._ch); |
| | | |
| | | if (!this._output.just_added_newline() && this._input.peek() === '\n' && insideNonSemiColonValues) { |
| | | this._output.add_new_line(); |
| | | } |
| | | } |
| | | } |
| | | |