private void writeElement(String indent, XhtmlNode node, boolean noPrettyOverride) throws IOException { if (!pretty || noPrettyOverride) indent = ""; // html self closing tags: http://xahlee.info/js/html5_non-closing_tag.html if (node.getChildNodes().size() == 0 && (xml || Utilities.existsInList(node.getName(), "area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source", "track", "wbr"))) dst.append(indent + "<" + node.getName() + attributes(node) + "/>" + (pretty && !noPrettyOverride ? "\r\n" : "")); else { boolean act = node.allChildrenAreText(); if (act || !pretty || noPrettyOverride) dst.append(indent + "<" + node.getName() + attributes(node)+">"); else dst.append(indent + "<" + node.getName() + attributes(node) + ">\r\n"); if (node.getName() == "head" && node.getElement("meta") == null) dst.append(indent + " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>" + (pretty && !noPrettyOverride ? "\r\n" : "")); for (XhtmlNode c : node.getChildNodes()) writeNode(indent + " ", c, noPrettyOverride || node.isNoPretty()); if (act) dst.append("</" + node.getName() + ">" + (pretty && !noPrettyOverride ? "\r\n" : "")); else if (node.getChildNodes().get(node.getChildNodes().size() - 1).getNodeType() == NodeType.Text) dst.append((pretty && !noPrettyOverride ? "\r\n"+ indent : "") + "</" + node.getName() + ">" + (pretty && !noPrettyOverride ? "\r\n" : "")); else dst.append(indent + "</" + node.getName() + ">" + (pretty && !noPrettyOverride ? "\r\n" : "")); } }
private void writeElement(String indent, XhtmlNode node, boolean noPrettyOverride) throws IOException { if (!pretty || noPrettyOverride) indent = ""; // html self closing tags: http://xahlee.info/js/html5_non-closing_tag.html if (node.getChildNodes().size() == 0 && (xml || Utilities.existsInList(node.getName(), "area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source", "track", "wbr"))) dst.append(indent + "<" + node.getName() + attributes(node) + "/>" + (pretty && !noPrettyOverride ? "\r\n" : "")); else { boolean act = node.allChildrenAreText(); if (act || !pretty || noPrettyOverride) dst.append(indent + "<" + node.getName() + attributes(node)+">"); else dst.append(indent + "<" + node.getName() + attributes(node) + ">\r\n"); if (node.getName() == "head" && node.getElement("meta") == null) dst.append(indent + " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>" + (pretty && !noPrettyOverride ? "\r\n" : "")); for (XhtmlNode c : node.getChildNodes()) writeNode(indent + " ", c, noPrettyOverride || node.isNoPretty()); if (act) dst.append("</" + node.getName() + ">" + (pretty && !noPrettyOverride ? "\r\n" : "")); else if (node.getChildNodes().get(node.getChildNodes().size() - 1).getNodeType() == NodeType.Text) dst.append((pretty && !noPrettyOverride ? "\r\n"+ indent : "") + "</" + node.getName() + ">" + (pretty && !noPrettyOverride ? "\r\n" : "")); else dst.append(indent + "</" + node.getName() + ">" + (pretty && !noPrettyOverride ? "\r\n" : "")); } }