use of net.htmlparser.jericho.Tag in project knox by apache.
the class HtmlFilterReaderBase method processCurrentSegment.
private void processCurrentSegment() {
Segment segment = parser.getCurrentSegment();
// ignore it as it was already output along with the previous tag.
if (segment.getEnd() <= lastSegEnd) {
return;
}
lastSegEnd = segment.getEnd();
if (segment instanceof Tag) {
if (segment instanceof StartTag) {
processStartTag((StartTag) segment);
} else if (segment instanceof EndTag) {
processEndTag((EndTag) segment);
} else {
writer.write(segment.toString());
}
} else {
processText(segment);
}
}
use of net.htmlparser.jericho.Tag in project vue-gwt by Axellience.
the class TemplateParser method processElement.
/**
* Recursive method that will process the whole template DOM tree.
* @param element Current element being processed
*/
private void processElement(Element element) {
context.setCurrentSegment(element);
currentProp = null;
currentAttribute = null;
Attributes attributes = element.getAttributes();
Attribute vForAttribute = attributes != null ? attributes.get("v-for") : null;
if (vForAttribute != null) {
// Add a context layer for our v-for
context.addContextLayer();
// Process the v-for expression, and update our attribute
String processedVForValue = processVForValue(vForAttribute.getValue());
outputDocument.replace(vForAttribute.getValueSegment(), processedVForValue);
}
// Process the element
if (attributes != null)
processElementAttributes(element);
// Process text segments
StreamSupport.stream(((Iterable<Segment>) element::getNodeIterator).spliterator(), false).filter(segment -> !(segment instanceof Tag) && !(segment instanceof CharacterReference)).filter(segment -> {
for (Element child : element.getChildElements()) if (child.encloses(segment))
return false;
return true;
}).forEach(this::processTextNode);
// Recurse downwards
element.getChildElements().forEach(this::processElement);
// After downward recursion, pop the context layer
if (vForAttribute != null)
context.popContextLayer();
}
Aggregations