Package org.jsoup.nodes

Examples of org.jsoup.nodes.TextNode


    void appendTextSkipHidden(Element e, StringBuilder accum) {
        for (Node child : e.childNodes()) {
            if (unlikely(child))
                continue;
            if (child instanceof TextNode) {
                TextNode textNode = (TextNode) child;
                String txt = textNode.text();
                accum.append(txt);
            } else if (child instanceof Element) {
                Element element = (Element) child;
                if (accum.length() > 0 && element.isBlock() && !lastCharIsWhitespace(accum))
                    accum.append(" ");
View Full Code Here


                } finally {
                    lexicalDescend(child, shouldPopScope);
                }

            } else if (n instanceof TextNode) {
              TextNode child = (TextNode)n;
              Renderable textWidget = null;
             
                //setup a lexical scope if we're going into a repeat widget (by reading the previous node)
                final boolean shouldPopScope = lexicalClimb(child);

                // construct the text widget
                try {
                  textWidget = registry.textWidget(cleanHtml(n), lexicalScopes.peek());
                 
                  // if there are no annotations, add the text widget to the chain
                  if (!child.hasAttr(ANNOTATION_KEY))  {
                    widgetChain.addWidget(textWidget);
                  }
                  else  {
                    // construct a new widget chain for this text node
                    WidgetChain childsChildren = Chains.proceeding().addWidget(textWidget);
                   
                    // make a new widget for the annotation, making the text chain the child
                    String widgetName = child.attr(ANNOTATION_KEY).toLowerCase();
                    Renderable annotationWidget = registry.newWidget(widgetName, child.attr(ANNOTATION_CONTENT), childsChildren, lexicalScopes.peek());
                    widgetChain.addWidget(annotationWidget);
                  }
                 
                } catch (ExpressionCompileException e) {
                    errors.add(
View Full Code Here

    public ElementUtil() {
    }

    public final static Element text(String text) {
        TextNode node = new TextNode(text, "");
        Element wrap = new GroupNode();
        wrap.appendChild(node);
        return wrap;
    }
View Full Code Here

    }

    @Override
    public void head(Node node, int depth) {
      if (node instanceof TextNode) {
        TextNode textNode = (TextNode) node;
        String text = textNode.text().replace('\u00A0', ' ').trim(); // non breaking space
        if (!text.isEmpty()) {
          buffer.append(text);
          if (!text.endsWith(" ")) {
            buffer.append(" ");
          }
View Full Code Here

    final StringBuilder buffer = new StringBuilder();
    new NodeTraversor(new NodeVisitor() {
      @Override
      public void head(Node node, int depth) {
        if (node instanceof TextNode) {
          TextNode textNode = (TextNode) node;
          String text = textNode.text().replace('\u00A0', ' ').trim(); // non breaking space
          if (!text.isEmpty()) {
            buffer.append(text);
            if (!text.endsWith(" ")) {
              buffer.append(" "); // the last text gets appended the extra space too but we remove it later
            }
View Full Code Here

        Node node;
        // characters in script and style go in as datanodes, not text nodes
        if (StringUtil.in(currentElement().tagName(), "script", "style"))
            node = new DataNode(characterToken.getData(), baseUri);
        else
            node = new TextNode(characterToken.getData(), baseUri);
        currentElement().appendChild(node); // doesn't use insertNode, because
                                            // we don't foster these; and will
                                            // always have a stack.
    }
View Full Code Here

    public ElementUtil() {
    }

    public final static Element text(String text) {
        TextNode node = new TextNode(text, "");
        Element wrap = new GroupNode();
        wrap.appendChild(node);
        return wrap;
    }
View Full Code Here

TOP

Related Classes of org.jsoup.nodes.TextNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.