fix calc whitespace (#71)

This commit is contained in:
Roland Fredenhagen 2023-02-01 00:57:10 +01:00 committed by GitHub
parent 45ad97e0be
commit 1e440a0d2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -5,7 +5,7 @@ use codemap::{CodeMap, Span};
use crate::{ use crate::{
ast::{CssStmt, MediaQuery, Style, SupportsRule}, ast::{CssStmt, MediaQuery, Style, SupportsRule},
color::{Color, ColorFormat, NAMED_COLORS}, color::{Color, ColorFormat, NAMED_COLORS},
common::{Brackets, ListSeparator, QuoteKind}, common::{BinaryOp, Brackets, ListSeparator, QuoteKind},
error::SassResult, error::SassResult,
selector::{ selector::{
Combinator, ComplexSelector, ComplexSelectorComponent, CompoundSelector, Namespace, Pseudo, Combinator, ComplexSelector, ComplexSelectorComponent, CompoundSelector, Namespace, Pseudo,
@ -358,7 +358,8 @@ impl<'a> Serializer<'a> {
self.buffer.push(b')'); self.buffer.push(b')');
} }
let operator_whitespace = !self.options.is_compressed() || op.precedence() == 1; let operator_whitespace =
!self.options.is_compressed() || matches!(op, BinaryOp::Plus | BinaryOp::Minus);
if operator_whitespace { if operator_whitespace {
self.buffer.push(b' '); self.buffer.push(b' ');

View File

@ -146,3 +146,9 @@ test!(
"a{color:a/b/c}", "a{color:a/b/c}",
grass::Options::default().style(grass::OutputStyle::Compressed) grass::Options::default().style(grass::OutputStyle::Compressed)
); );
test!(
calc,
"a {\n width: calc(100% + 32px);\n}\n",
"a{width:calc(100% + 32px)}",
grass::Options::default().style(grass::OutputStyle::Compressed)
);