diff --git a/javascript/packages/formatter/src/format-printer.ts b/javascript/packages/formatter/src/format-printer.ts index bf6c0f1cc..20f8f4678 100644 --- a/javascript/packages/formatter/src/format-printer.ts +++ b/javascript/packages/formatter/src/format-printer.ts @@ -1179,6 +1179,14 @@ export class FormatPrinter extends Printer { } }).join("") + const trimmedInner = inner.trim() + + if (trimmedInner.startsWith('[if ') && trimmedInner.endsWith(' { + beforeAll(async () => { + await Herb.load() + + formatter = new Formatter(Herb, { + indentWidth: 2, + maxLineLength: 80 + }) + }) + + test("preserves conditional comment syntax on same line - issue #877", () => { + const source = dedent` + + ` + const result = formatter.format(source) + expect(result).toEqual(source) + }) + + test("handles conditional comment with content", () => { + const source = dedent` + + ` + const result = formatter.format(source) + expect(result).toEqual(source) + }) + + test("handles negated conditional comment", () => { + const source = dedent` + +
Not Outlook
+ + ` + const result = formatter.format(source) + expect(result).toEqual(source) + }) + + test("handles conditional comment with ERB interpolation", () => { + const source = dedent` + + ` + const result = formatter.format(source) + expect(result).toEqual(source) + }) +})