Package org.jsoup.nodes

Examples of org.jsoup.nodes.TextNode


                continue;
            }
            for (Element child : element.children().select(tag)) {
                cleanNodes(child, tag);
            }
            element.replaceWith(new TextNode(element.text() + "<br/>", ""));
        }
    }
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

                System.out.println("(!) Error: No parameters were given for command " + command);
              }
            } else if (command.equals("##players") && !hasPlayersList) {
              //System.out.printf("Players list found: ");
              // get the html of the ##players list
              TextNode t = TextNode.createFromEncoded(aBoldTag.html(), "aURI");
              // make an array with each element containing a player name
              String[] playerList = t.getWholeText().split("<br />\\s*");
              // create the internal player list using the array
              actors = new Actors(Arrays.copyOfRange(playerList, 1, playerList.length));
              hasPlayersList = true;
            } else if (command.equals("##gm")) {
              addGM(parameter);
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

    if(isBlock(prev)) {
      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)) {
        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

    Options.InWordEmphasis iwe = converter.options.getInWordEmphasis();
    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();
        }
      }
      // 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

                } finally {
                    lexicalDescend(pc, child, shouldPopScope);
                }

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

                // construct the text widget
                try {
                  textWidget = registry.textWidget(cleanHtml(n), pc.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, pc.lexicalScopes.peek());
                    widgetChain.addWidget(annotationWidget);
                  }
                 
                } catch (ExpressionCompileException e) {
                    pc.errors.add(
View Full Code Here

   
    if (annotation != null)
      lines = splitInTwo(text);
   
    for (int i = 0; i < lines.length; i++){
      TextNode textNode = TextNode.createFromEncoded(lines[i], baseUri);
      lines(textNode, lines[i]);
     
      // apply the annotation and reset it to null
      if (annotation != null && i == 0)
        annotation.apply(textNode);
View Full Code Here

    String rawText = tq.consumeTo("<");
    String annotationText = AnnotationParser.readAnnotation(rawText);
    String text = AnnotationParser.stripAnnotation(rawText);

    if (text.length() > 0) {
      TextNode textNode = TextNode.createFromEncoded(text, baseUri);
      // if (pendingAnnotation != null) { pendingAnnotation.apply(textNode); }
      lines(textNode, rawText);
      add(textNode);
    }
View Full Code Here

  }

  private void parseCdata() {
    tq.consume("<![CDATA[");
    String rawText = tq.chompTo("]]>");
    TextNode textNode = new TextNode(rawText, baseUri); // constructor does not escape

    if (pendingAnnotation != null)
      pendingAnnotation.apply(textNode);

    lines(textNode, rawText);
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.