public OutputDocument getOutputDocument() { return new OutputDocument(fSource); }
/** * Causes the specified range of the source text to be ignored when parsing. * <p> * See the documentation of the {@link Segment#ignoreWhenParsing()} method for more information. * * @param begin the beginning character position in the source text. * @param end the end character position in the source text. */ public void ignoreWhenParsing(final int begin, final int end) { if (wasFullSequentialParseCalled()) throw new IllegalStateException("ignoreWhenParsing can not be used after a full sequential parse has been performed"); if (parseTextOutputDocument==null) { parseTextOutputDocument=new OutputDocument(getParseText()); parseText=null; } parseTextOutputDocument.replaceWithSpaces(begin,end); }
public String filter(String key, String value) { Source source = new Source(value); OutputDocument document = new OutputDocument(source); replaceChildren(source, source, document); return document.toString(); }
public String filter(String key, String value) { Source source = new Source(value); OutputDocument document = new OutputDocument(source); replaceChildren(source, source, document); return document.toString(); }
public static String removeSpans(String html) { Source source = new Source(html); source.fullSequentialParse(); OutputDocument outputDocument = new OutputDocument(source); List<Tag> tags = source.getAllTags(); for (Tag tag : tags) { String tagname = tag.getName().toLowerCase(); if (tagname.equals("span")) { //remove the <span> outputDocument.remove(tag); } } return outputDocument.toString(); }
OutputDocument outputDocument = new OutputDocument(source);
OutputDocument outputDocument=new OutputDocument(source); for (Element element : source.getAllElementsByClass("constantValuesContainer"))
private String removeNotAllowedTags(String htmlFragment, URI docUri) { Source source = new Source(htmlFragment); OutputDocument outputDocument = new OutputDocument(source); List<Element> elements = source.getAllElements();
OutputDocument doc = new OutputDocument(source); List<Tag> tags = source.getAllTags(); int pos = 0;
@Override public String filter(String source, Map<String, Object> properties) { Source sourceHtml = new Source(source); sourceHtml.setLogger(null); sourceHtml.fullSequentialParse(); OutputDocument outputDocument = new OutputDocument(sourceHtml); List<Tag> tags = sourceHtml.getAllTags(); int pos = 0; for (Tag tag : tags) { boolean correctAndAllowedTag = processTag(tag, outputDocument); if (!correctAndAllowedTag) { String elementName = tag.getName().toLowerCase(); if (removedTags.contains(elementName) || allowedTags.contains(elementName)) { outputDocument.remove(tag); } else { outputDocument.replace(tag, StringEscapeUtils.escapeHtml(tag.toString())); } } reencodeTextSegment(sourceHtml, outputDocument, pos, tag.getBegin()); pos = tag.getEnd(); } reencodeTextSegment(sourceHtml, outputDocument, pos, sourceHtml.getEnd()); return correctNewLineSigns(outputDocument.toString(), properties); }
Source sourceHtml = new Source(source); sourceHtml.setLogger(null); OutputDocument outputDocument = new OutputDocument(sourceHtml); List<StartTag> tags = sourceHtml.getAllStartTags(FORMULA_TAG_NAME); for (StartTag tag : tags) {
/** * Parse a given HTML template and return the a result object containing the expressions and a * transformed HTML. * * @param htmlTemplate The HTML template to process, as a String * @param context Context of the Component we are currently processing * @param messager Used to report errors in template during Annotation Processing * @return A {@link TemplateParserResult} containing the processed template and expressions */ public TemplateParserResult parseHtmlTemplate(String htmlTemplate, TemplateParserContext context, Elements elements, Messager messager, URI htmlTemplateUri) { this.context = context; this.elements = elements; this.messager = messager; this.logger = new TemplateParserLogger(context, messager); this.htmlTemplateUri = htmlTemplateUri; initJerichoConfig(this.logger); Source source = new Source(htmlTemplate); outputDocument = new OutputDocument(source); result = new TemplateParserResult(context); processImports(source); result.setScopedCss(processScopedCss(source)); source.getChildElements().forEach(this::processElement); result.setProcessedTemplate(outputDocument.toString()); return result; }