diff --git a/src/lib/index.ts b/src/lib/index.ts index 2577e72..7e7ad9e 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -433,7 +433,7 @@ export function format( return prelude .replace(/\s*([:,])/g, prelude.toLowerCase().includes('selector(') ? '$1' : '$1 ') // force whitespace after colon or comma, except inside `selector()` .replace(/\)([a-zA-Z])/g, ') $1') // force whitespace between closing parenthesis and following text (usually and|or) - .replace(/\s*(=>|<=)\s*/g, ' $1 ') // force whitespace around => and <= + .replace(/\s*(=>|>=|<=)\s*/g, `${OPTIONAL_SPACE}$1${OPTIONAL_SPACE}`) // add optional spacing around =>, >= and <= .replace(/([^<>=\s])([<>])([^<>=\s])/g, `$1${OPTIONAL_SPACE}$2${OPTIONAL_SPACE}$3`) // add spacing around < or > except when it's part of <=, >=, => .replace(/\s+/g, OPTIONAL_SPACE) // collapse multiple whitespaces into one .replace( diff --git a/test/atrules.test.ts b/test/atrules.test.ts index ed7379f..20d9ad9 100644 --- a/test/atrules.test.ts +++ b/test/atrules.test.ts @@ -114,6 +114,7 @@ test('@media prelude formatting', () => { `@media (min-width: 1024px)or (max-width: 1439px) {}`, `@media (min-width: 1024px) or (max-width: 1439px) {}`, ], + [`@media (width>=44rem)or (width<=33rem) {}`, `@media (width >= 44rem) or (width <= 33rem) {}`], [ `@media all and (transform-3d), (-webkit-transform-3d) {}`, `@media all and (transform-3d), (-webkit-transform-3d) {}`,