Output Formatting

Starting with version 0.9.16 CSSParser includes limited support of output formatting. At the moment the formatter uses a fixed layout.
There is an option that forces for the output of color values as hex instead of rgb. Additionally there is an option that forces placing of every property from a rule in a separate line.

If you need more options, please open a ticket.

InputSource source = new InputSource(new StringReader("h1{background:rgb(7,42,0)}"));
CSSOMParser parser = new CSSOMParser(new SACParserCSS3());
CSSStyleSheetImpl sheet = (CSSStyleSheetImpl) parser.parseStyleSheet(source, null, null);

Assert.assertEquals("h1 { background: rgb(7, 42, 0) }", sheet.getCssText());

Assert.assertEquals("h1 { background: #072a00 }", sheet.getCssText(new CSSFormat().setRgbAsHex(true)));

Assert.assertEquals("h1 {" + NEW_LINE + "    background: rgb(7, 42, 0)" + NEW_LINE + "}", sheet.getCssText(new CSSFormat().setPropertiesInSeparateLines(4)));