Example usage for org.jsoup.nodes TextNode toString

List of usage examples for org.jsoup.nodes TextNode toString

Introduction

In this page you can find the example usage for org.jsoup.nodes TextNode toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:org.jsweet.input.typescriptdef.visitor.DocFiller.java

public void head(Node node, int depth) {
    String name = node.nodeName();
    if (!tagsToBeRemoved.contains(name)) {
        if (node instanceof TextNode) {
            TextNode tn = (TextNode) node;
            out.append(tn.toString());
        } else {/*from  w w w.j  a v a 2 s  .c  o m*/
            out.append("<" + name + ">");
        }
    }
}

From source file:utils.AutoLinkRenderer.java

private AutoLinkRenderer parse(Pattern pattern, ToLink toLink) {
    Document doc = Jsoup.parse(body);

    Document.OutputSettings settings = doc.outputSettings();
    settings.prettyPrint(false);//from  w  w w.  ja v  a 2s .co m

    Elements elements = doc.getElementsMatchingOwnText(pattern);

    for (Element el : elements) {
        if (isIgnoreElement(el)) {
            continue;
        }

        List<TextNode> textNodeList = el.textNodes();

        for (TextNode node : textNodeList) {
            String result = convertLink(node.toString(), pattern, toLink);
            node.text(StringUtils.EMPTY);
            node.after(result);
        }
    }

    this.body = doc.body().html();
    return this;
}