EclipseHtmlFormatterStepImpl extends CleanupStep { @Override public String format(String raw) throws Exception { raw = super.format(raw); IStructuredDocument document = (IStructuredDocument) new HTMLDocumentLoader().createNewStructuredDocument(); document.setPreferredLineDelimiter(LINE_DELIMITER); document.set(raw); StructuredDocumentProcessor<CodeFormatter> jsProcessor = new StructuredDocumentProcessor<CodeFormatter>( document, IHTMLPartitions.SCRIPT, JsRegionProcessor.createFactory(htmlFormatterIndent)); jsProcessor.apply(jsFormatter); return document.get(); } EclipseHtmlFormatterStepImpl(Properties properties); @Override String format(String raw);  }
@Test public void formatHtml4() throws Exception { String[] input = testData.input("html4.html"); String output = formatter.format(input[0]); assertEquals("Unexpected HTML4 formatting.", testData.expected("html4.html"), output); }
@Test public void formatHtml5() throws Exception { String[] input = testData.input("html5.html"); String output = formatter.format(input[0]); assertEquals("Unexpected HTML5 formatting.", testData.expected("html5.html"), output); }
@Test public void invalidSyntax() throws Exception { String[] input = testData.input("invalid_syntax.html"); String output = formatter.format(input[0]); assertEquals("Unexpected HTML formatting in case syntax is not valid.", testData.expected("invalid_syntax.html"), output); }
@Test public void formatJavaScript() throws Exception { String[] input = testData.input("javascript.html"); String output = formatter.format(input[0]); assertEquals("Unexpected JS formatting.", testData.expected("javascript.html"), output); }
@Test public void formatCSS() throws Exception { String[] input = testData.input("css.html"); String output = formatter.format(input[0]); assertEquals("Unexpected CSS formatting.", testData.expected("css.html"), output); }
@Test public void checkCleanupForNonUtf8() throws Exception { String osEncoding = System.getProperty("file.encoding"); System.setProperty("file.encoding", "ISO-8859-1"); String[] input = testData.input("utf-8.html"); String output = formatter.format(input[0]); System.setProperty("file.encoding", osEncoding); assertEquals("Unexpected formatting of UTF-8", testData.expected("utf-8.html"), output); }
@Test public void checkBOMisStripped() throws Exception { String[] input = testData.input("bom.html"); String[] inputWithoutBom = testData.input("utf-8.html"); assertEquals("BOM input invalid", input[0].length() - 1, inputWithoutBom[0].length()); String output = formatter.format(input[0]); assertEquals("BOM is not stripped", testData.expected("utf-8.html"), output); }