Example usage for org.jsoup.nodes Element isBlock

List of usage examples for org.jsoup.nodes Element isBlock

Introduction

In this page you can find the example usage for org.jsoup.nodes Element isBlock.

Prototype

public boolean isBlock() 

Source Link

Document

Test if this element is a block-level element.

Usage

From source file:by.heap.remark.convert.TextCleaner.java

private boolean isBlock(Node n) {
    boolean block = false;
    if (n != null && n instanceof Element) {
        Element el = (Element) n;
        block = el.isBlock() || el.tagName().equals("br");
    }// w  ww. j  av  a 2  s .  c om
    return block;
}

From source file:org.structr.web.common.microformat.MicroformatParser.java

private void unwrap(final Element element) {

    final Set<Element> elementsToUnwrap = new LinkedHashSet<>();

    element.traverse(new NodeVisitor() {

        @Override// www.j a va  2 s  . c  o  m
        public void head(Node node, int depth) {

            if (node instanceof Element) {

                final Element element = (Element) node;

                if (element.isBlock()) {
                    final Set<String> classes = element.classNames();

                    removeEmpty(classes);

                    if (classes.isEmpty()) {
                        elementsToUnwrap.add(element);
                    }
                }
            }
        }

        @Override
        public void tail(Node node, int depth) {
        }
    });

    for (final Element unwrap : elementsToUnwrap) {
        unwrap.unwrap();
    }
}