void outerHtmlTail(Appendable accum, int depth, Document.OutputSettings out) throws IOException { if (!(childNodes.isEmpty() && tag.isSelfClosing())) { if (out.prettyPrint() && (!childNodes.isEmpty() && ( tag.formatAsBlock() || (out.outline() && (childNodes.size()>1 || (childNodes.size()==1 && !(childNodes.get(0) instanceof TextNode)))) ))) indent(accum, depth, out); accum.append("</").append(tagName()).append('>'); } }
void outerHtmlHead(final Appendable accum, int depth, final Document.OutputSettings out) throws IOException { if (out.prettyPrint() && (tag.formatAsBlock() || (parent() != null && parent().tag().formatAsBlock()) || out.outline())) { if (accum instanceof StringBuilder) { if (((StringBuilder) accum).length() > 0) indent(accum, depth, out); } else { indent(accum, depth, out); } } accum.append('<').append(tagName()); if (attributes != null) attributes.html(accum, out); // selfclosing includes unknown tags, isEmpty defines tags that are always empty if (childNodes.isEmpty() && tag.isSelfClosing()) { if (out.syntax() == Document.OutputSettings.Syntax.html && tag.isEmpty()) accum.append('>'); else accum.append(" />"); // <img> in html, <img /> in xml } else accum.append('>'); }
void outerHtmlHead(Appendable accum, int depth, Document.OutputSettings out) throws IOException { if (out.prettyPrint() && ((siblingIndex() == 0 && parentNode instanceof Element && ((Element) parentNode).tag().formatAsBlock() && !isBlank()) || (out.outline() && siblingNodes().size()>0 && !isBlank()) )) indent(accum, depth, out); boolean normaliseWhite = out.prettyPrint() && parent() instanceof Element && !Element.preserveWhitespace(parent()); Entities.escape(accum, coreValue(), out, false, normaliseWhite, false); }
outSettings.charset(Charsets.UTF_16); outSettings.syntax(Syntax.xml); outSettings.outline(true); outSettings.prettyPrint(false);
outSettings.charset(Charsets.UTF_16); outSettings.syntax(Syntax.xml); outSettings.outline(true); outSettings.prettyPrint(false);
outSettings.charset(Charsets.UTF_16); outSettings.syntax(Syntax.xml); outSettings.outline(true); outSettings.prettyPrint(false);
@Override public String stripHtmlFromText(String text, boolean smartSpacing, boolean stripEscapeSequences) { if (StringUtils.isBlank(text)) return text; if (smartSpacing) { text = text.replaceAll("/br>", "/br> ").replaceAll("/p>", "/p> ").replaceAll("/tr>", "/tr> "); } if (stripEscapeSequences) { org.jsoup.nodes.Document document = org.jsoup.Jsoup.parse(text); org.jsoup.nodes.Element body = document.body(); //remove any html tags, unescape any escape characters text = body.text(); // are converted to char code 160, java doesn't treat it like whitespace, so replace it with ' ' text = text.replace((char)160, ' '); } else { text = org.jsoup.Jsoup.clean(text, "", org.jsoup.safety.Whitelist.none(), new org.jsoup.nodes.Document.OutputSettings().prettyPrint(false).outline(false)); } if (smartSpacing || stripEscapeSequences) { text = text.replaceAll("\\s+", " "); } return text.trim(); }
void outerHtmlHead(StringBuilder accum, int depth, Document.OutputSettings out) { if ((out.prettyPrint()) && ((((siblingIndex() == 0) && (this.parentNode instanceof Element) && (((Element) this.parentNode).tag().formatAsBlock()) && (!(isBlank()))) || ((out .outline()) && (siblingNodes().size() > 0) && (!(isBlank())))))) { indent(accum, depth, out); } boolean normaliseWhite = (out.prettyPrint()) && (parent() instanceof Element) && (!(Element.preserveWhitespace(parent()))); Entities.escape(accum, getWholeText(), out, false, normaliseWhite, false); }