Java Code Examples for org.jsoup.nodes.Document.OutputSettings#prettyPrint()
The following examples show how to use
org.jsoup.nodes.Document.OutputSettings#prettyPrint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XHTMLDocumentHandler.java From docx4j-template with Apache License 2.0 | 6 votes |
/** * Jsoup.parse(in, charsetName, baseUri) */ @Override public Document handle( InputStream input) throws IOException{ //获取Jsoup参数 String charsetName = Docx4jProperties.getProperty(Docx4jConstants.DOCX4J_JSOUP_PARSE_CHARSETNAME, Docx4jConstants.DEFAULT_CHARSETNAME ); String baseUri = Docx4jProperties.getProperty(Docx4jConstants.DOCX4J_JSOUP_PARSE_BASEURI,""); //使用Jsoup将html转换成Document对象 Document doc = Jsoup.parse(input, charsetName, baseUri); OutputSettings outputSettings = new OutputSettings(); outputSettings.prettyPrint(false); /* outputSettings.syntax(syntax) outputSettings.charset(charset) outputSettings*/ doc.outputSettings(outputSettings); //返回Document对象 return doc; }
Example 2
Source File: JsoupBasedFormatter.java From formatter-maven-plugin with Apache License 2.0 | 5 votes |
@Override public void init(Map<String, String> options, ConfigurationSource cfg) { super.initCfg(cfg); formatter = new OutputSettings(); formatter.charset(Charset.forName(options.getOrDefault("charset", StandardCharsets.UTF_8.name()))); formatter.escapeMode(EscapeMode.valueOf(options.getOrDefault("escapeMode", EscapeMode.xhtml.name()))); formatter.indentAmount(Integer.parseInt(options.getOrDefault("indentAmount", "4"))); formatter.outline(Boolean.parseBoolean(options.getOrDefault("outlineMode", Boolean.TRUE.toString()))); formatter.prettyPrint(Boolean.parseBoolean(options.getOrDefault("pretty", Boolean.TRUE.toString()))); formatter.syntax(Syntax.valueOf(options.getOrDefault("syntax", Syntax.html.name()))); }
Example 3
Source File: DocumentTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testHtmlAppendable() { String htmlContent = "<html><head><title>Hello</title></head><body><p>One</p><p>Two</p></body></html>"; Document document = Jsoup.parse(htmlContent); OutputSettings outputSettings = new OutputSettings(); outputSettings.prettyPrint(false); document.outputSettings(outputSettings); assertEquals(htmlContent, document.html(new StringWriter()).toString()); }
Example 4
Source File: DocumentTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testHtmlAppendable() { String htmlContent = "<html><head><title>Hello</title></head><body><p>One</p><p>Two</p></body></html>"; Document document = Jsoup.parse(htmlContent); OutputSettings outputSettings = new OutputSettings(); outputSettings.prettyPrint(false); document.outputSettings(outputSettings); assertEquals(htmlContent, document.html(new StringWriter()).toString()); }
Example 5
Source File: DocumentTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testHtmlAppendable() { String htmlContent = "<html><head><title>Hello</title></head><body><p>One</p><p>Two</p></body></html>"; Document document = Jsoup.parse(htmlContent); OutputSettings outputSettings = new OutputSettings(); outputSettings.prettyPrint(false); document.outputSettings(outputSettings); assertEquals(htmlContent, document.html(new StringWriter()).toString()); }