Package org.jsoup.nodes

Examples of org.jsoup.nodes.TextNode.text()


    @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


    protected String getText(Element element) {
        StringBuilder accum = new StringBuilder();
        for (Node node : element.childNodes()) {
            if (node instanceof TextNode) {
                TextNode textNode = (TextNode) node;
                accum.append(textNode.text());
            }
        }
        return accum.toString();
    }
View Full Code Here

      input = ltrim(input);
    } else if(prev == null && parentIsBlock) {
      input = ltrim(input);
    } else if(normalText && prev instanceof TextNode) {
      TextNode tprev = (TextNode)prev;
      if(EMPTY_MATCHER.matcher(tprev.text()).matches()) {
        input = ltrim(input);
      }
    }
    if(input.length() > 0) {
      if(isBlock(next)) {
View Full Code Here

        input = rtrim(input);
      } else if(next == null && parentIsBlock) {
        input = rtrim(input);
      } else if(normalText && next instanceof TextNode) {
        TextNode tnext = (TextNode)next;
        if(EMPTY_MATCHER.matcher(tnext.text()).matches()) {
          input = rtrim(input);
        }
      }
    }
    return input;
View Full Code Here

    if(!iwe.isEmphasisPreserved() || iwe.isAdditionalSpacingNeeded()) {
      // peek behind for inline styling
      Node n = node.previousSibling();
      if(n != null && n instanceof TextNode) {
        TextNode tn = (TextNode)n;
        String text = tn.text();
        if(INWORD_CHARACTER.matcher(text.substring(text.length()-1)).matches()) {
          result.emphasisPreserved = iwe.isEmphasisPreserved();
          result.addSpacing = iwe.isAdditionalSpacingNeeded();
        }
      }
View Full Code Here

      }
      // peek ahead for inline styling
      n = node.nextSibling();
      if(n != null && n instanceof TextNode) {
        TextNode tn = (TextNode)n;
        if(INWORD_CHARACTER.matcher(tn.text().substring(0,1)).matches()) {
          result.emphasisPreserved = iwe.isEmphasisPreserved();
          result.addSpacing = iwe.isAdditionalSpacingNeeded();
        }
      }
    }
View Full Code Here

        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

    @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

    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

TOP
Copyright © 2018 www.massapi.com. 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.