private static synchronized void initCleaner() { if (!htmlCleanerInitialized) { cleaner = new HtmlCleaner(); CleanerProperties props = cleaner.getProperties(); props.setOmitComments(true); props.setOmitXmlDeclaration(true); htmlCleanerInitialized = true; } }
private String wrap(Object text, HtmlCleaner htmlCleaner) { if (text != null) { if (text instanceof TagNode) { final CleanerProperties cleanerProperties = htmlCleaner.getProperties(); cleanerProperties.setOmitXmlDeclaration(true); final HtmlSerializer htmlSerializer = new PrettyHtmlSerializer(cleanerProperties); final String html = htmlSerializer.getAsString((TagNode) text); return html; } else { return TypeUtils.castToString(text); } } return ""; } }
/** * Creates a <code>HtmlCleaner</code> instance. * By default, it sets the following properties to the <code>HtmlCleaner</code>: * <ul> * <li>omitXmlDeclaration : true</li> * <li>omitDoctypeDeclaration : true</li> * </ul> * @return */ protected HtmlCleaner createHtmlCleaner() { HtmlCleaner htmlCleaner = new HtmlCleaner(); htmlCleaner.getProperties().setOmitXmlDeclaration(true); htmlCleaner.getProperties().setOmitDoctypeDeclaration(true); return htmlCleaner; } }
public Set<String> validateNonEmpty(String html) { final Set<String> result = new HashSet<>(); final HtmlCleaner cleaner = new HtmlCleaner(); final CleanerProperties properties = cleaner.getProperties(); properties.setOmitXmlDeclaration(true); properties.setOmitHtmlEnvelope(true); properties.setOmitComments(true); properties.setNamespacesAware(false); properties.setDeserializeEntities(true); if (isEmpty(cleaner.clean(html))) { result.add(ValidatorMessages.HTML_IS_EMPTY); } return result; }
private static CleanerProperties createCleanerProperties() { final CleanerProperties properties = new CleanerProperties() { // CHECKSTYLE:OFF analogous to the implementation that gets fixed here. ITagInfoProvider tagInfoProvider = new DefaultTagProvider(); // NOPMD // CHECKSTYLE:ON @Override public ITagInfoProvider getTagInfoProvider() { return tagInfoProvider; } }; properties.setOmitHtmlEnvelope(true); properties.setOmitDoctypeDeclaration(true); properties.setOmitXmlDeclaration(true); properties.setUseEmptyElementTags(true); return properties; }
props.setOmitXmlDeclaration( toBoolean(omitXmlDeclaration) );
props.setOmitXmlDeclaration(toBoolean(omitXmlDeclaration));
props.setTreatDeprecatedTagsAsContent(this.treatdeprtagsascontent); props.setOmitComments(this.omitcomments); props.setOmitXmlDeclaration(this.omitxmldecl); props.setOmitDoctypeDeclaration(this.omitdoctypedecl); props.setOmitHtmlEnvelope(this.omithtmlenvelope);
public HtmlProcessorImpl(final HtmlProcessorConfig config) { this.config = config; final CleanerProperties properties = new CleanerProperties(); properties.setOmitHtmlEnvelope(true); properties.setOmitXmlDeclaration(true); properties.setOmitComments(config.isOmitComments()); parser = new HtmlCleaner(properties); filter = new WhitelistHtmlFilter(config.getWhitelistElements(), config.isOmitJavascriptProtocol()); serializer = HtmlSerializerFactory.create(config.getSerializer(), properties); }
props.setOmitUnknownTags(true); props.setOmitDoctypeDeclaration(true); props.setOmitXmlDeclaration(true); props.setRecognizeUnicodeChars(false); props.setAdvancedXmlEscape(true);