org.jsoup.nodes.DocumentType Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of html2pdf Show documentation
Show all versions of html2pdf Show documentation
pdfHTML is an iText 7 add-on that lets you to parse (X)HTML snippets and the associated CSS and converts
them to PDF.
package org.jsoup.nodes;
import java.io.IOException;
import org.jsoup.helper.StringUtil;
import org.jsoup.nodes.Document.OutputSettings.*;
/**
* A {@code } node.
*/
public class DocumentType extends Node {
private static final String NAME = "name";
private static final String PUBLIC_ID = "publicId";
private static final String SYSTEM_ID = "systemId";
// todo: quirk mode from publicId and systemId
/**
* Create a new doctype element.
* @param name the doctype's name
* @param publicId the doctype's public ID
* @param systemId the doctype's system ID
* @param baseUri the doctype's base URI
*/
public DocumentType(String name, String publicId, String systemId, String baseUri) {
super(baseUri);
attr(NAME, name);
attr(PUBLIC_ID, publicId);
attr(SYSTEM_ID, systemId);
}
@Override
public String nodeName() {
return "#doctype";
}
@Override
void outerHtmlHead(Appendable accum, int depth, Document.OutputSettings out) throws IOException {
if (out.syntax() == Syntax.html && !has(PUBLIC_ID) && !has(SYSTEM_ID)) {
// looks like a html5 doctype, go lowercase for aesthetics
accum.append("');
}
@Override
void outerHtmlTail(Appendable accum, int depth, Document.OutputSettings out) {
}
private boolean has(final String attribute) {
return !StringUtil.isBlank(attr(attribute));
}
}