Examples of TagNode


Examples of info.bliki.htmlcleaner.TagNode

    }
    addToTableOfContent(fTableOfContent, tocHead, anchor, headLevel);
    if (getRecursionLevel() == 1) {
      buildEditLinkUrl(fSectionCounter++);
    }
    TagNode aTagNode = new TagNode("a");
    aTagNode.addAttribute("name", anchor, true);
    aTagNode.addAttribute("id", anchor, true);
    append(aTagNode);

    append(headTagNode);
    return fTableOfContentTag;
  }
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

      buf.append('>');
    }
  }

  public void renderHTMLWithoutTag(ITextConverter converter, Appendable buf, IWikiModel model) throws IOException {
    TagNode node = this;
    List<Object> children = node.getChildren();
    if (children.size() != 0) {
      converter.nodesToText(children, buf, model);
    }
  }
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

    super("ref");
  }

  @Override
  public void renderHTML(ITextConverter converter, Appendable writer, IWikiModel model) throws IOException {
    TagNode node = this;
    List<Object> children = node.getChildren();
    int len = children.size();
    StringBuilder buf = null;
    if (len == 0) {
      buf = new StringBuilder(16);
    } else {
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

  }

  private boolean createBBCode(String bbStr, String bbAttr, String innerTag) {
    if (bbStr.equals("code")) {
      TagNode preTagNode = new TagNode("pre");
      preTagNode.addAttribute("class", "code", true);
      preTagNode.addChild(new ContentToken(innerTag));
      fWikiModel.append(preTagNode);
      return true;
    } else if (bbStr.equals("color")) {
      if (bbAttr == null) {
        return false;
      }
      TagNode fontTagNode = new TagNode("font");
      fontTagNode.addAttribute("color", bbAttr, true);
      fontTagNode.addChild(new ContentToken(innerTag));
      fWikiModel.append(fontTagNode);

      return true;
    } else if (bbStr.equals("email")) {
      TagNode aTagNode = new TagNode("a");
      aTagNode.addAttribute("href", "emailto:" + innerTag.trim(), true);
      aTagNode.addChild(new ContentToken(innerTag));
      fWikiModel.append(aTagNode);

      return true;
    } else if (bbStr.equals("list")) {
      int listStart = 0;
      int listEnd = 0;
      TagNode listTagNode;
      if (bbAttr != null) {
        if (bbAttr.equals("a")) {
          listTagNode = new TagNode("ul");
        } else {
          listTagNode = new TagNode("ol");
        }
      } else {
        listTagNode = new TagNode("ul");
      }
      fWikiModel.pushNode(listTagNode);
      try {
        while (listEnd >= 0) {
          listEnd = innerTag.indexOf("[*]", listStart);
          if (listEnd > listStart) {
            if (listStart == 0) {
              parseNextPHPBBCode(innerTag.substring(0, listEnd));
              // fWikiModel.append(new ContentToken(innerTag.substring(0,
              // listEnd)));
            } else {
              listTagNode = new TagNode("li");
              fWikiModel.pushNode(listTagNode);
              try {
                parseNextPHPBBCode(innerTag.substring(listStart, listEnd));
                // listTagNode.addChild(new
                // ContentToken(innerTag.substring(listStart, listEnd)));
              } finally {
                fWikiModel.popNode();
              }
            }
            listStart = listEnd + 3;
          }
        }
        if (listStart == 0) {
          parseNextPHPBBCode(innerTag);
          // fWikiModel.append(new ContentToken(innerTag));
        } else {
          if (listStart < innerTag.length()) {
            listTagNode = new TagNode("li");
            fWikiModel.pushNode(listTagNode);
            try {
              parseNextPHPBBCode(innerTag.substring(listStart, innerTag.length()));
              // listTagNode.addChild(new
              // ContentToken(innerTag.substring(listStart,
              // innerTag.length())));
              // fWikiModel.append(listTagNode);
            } finally {
              fWikiModel.popNode();
            }
          }
        }

      } finally {
        fWikiModel.popNode();
      }
      return true;
    } else if (bbStr.equals("img")) {
      TagNode imgTagNode = new TagNode("img");
      imgTagNode.addAttribute("src", innerTag.trim(), true);
      imgTagNode.addChild(new ContentToken(innerTag));
      fWikiModel.append(imgTagNode);

      return true;
    } else if (bbStr.equals("quote")) {
      TagNode quoteTagNode = new TagNode("blockquote");
      // quoteTagNode.addChild(new ContentToken(innerTag));
      fWikiModel.pushNode(quoteTagNode);
      try {
        parseNextPHPBBCode(innerTag);
      } finally {
        fWikiModel.popNode();
      }
      return true;
    } else if (bbStr.equals("size")) {
      if (bbAttr == null) {
        return false;
      }
      TagNode fontTagNode = new TagNode("font");
      fontTagNode.addAttribute("size", bbAttr, true);
      fontTagNode.addChild(new ContentToken(innerTag));
      fWikiModel.append(fontTagNode);

      return true;
    } else if (bbStr.equals("url")) {
      if (bbAttr != null) {
        TagNode aTagNode = new TagNode("a");
        aTagNode.addAttribute("href", bbAttr, true);
        aTagNode.addChild(new ContentToken(innerTag));
        fWikiModel.append(aTagNode);

        return true;
      } else {
        TagNode aTagNode = new TagNode("a");
        aTagNode.addAttribute("href", innerTag.trim(), true);
        aTagNode.addChild(new ContentToken(innerTag));
        fWikiModel.append(aTagNode);

        return true;
      }
    } else if (bbStr.equals("b")) {
      TagNode boldTagNode = new TagNode("b");
      boldTagNode.addChild(new ContentToken(innerTag));
      fWikiModel.append(boldTagNode);
      return true;
    } else if (bbStr.equals("i")) {
      TagNode italicTagNode = new TagNode("i");
      italicTagNode.addChild(new ContentToken(innerTag));
      fWikiModel.append(italicTagNode);
      return true;
    } else if (bbStr.equals("u")) {
      TagNode underlineTagNode = new TagNode("u");
      underlineTagNode.addChild(new ContentToken(innerTag));
      fWikiModel.append(underlineTagNode);
      return true;
    }

    return false;
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

  public void append(BaseToken contentNode) {
    fTagStack.append(contentNode);
  }

  public void appendExternalImageLink(String imageSrc, String imageAltText) {
    TagNode spanTagNode = new TagNode("span");
    append(spanTagNode);
    spanTagNode.addAttribute("class", "image", true);
    TagNode imgTagNode = new TagNode("img");
    spanTagNode.addChild(imgTagNode);
    imgTagNode.addAttribute("src", imageSrc, true);
    imgTagNode.addAttribute("alt", imageAltText, true);
    // "nofollow" keyword is not allowed for XHTML
    // imgTagNode.addAttribute("rel", "nofollow", true);
  }
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

    // || ext.equalsIgnoreCase("bmp")) {
    // appendExternalImageLink(link, linkName);
    // return;
    // }
    // }
    TagNode aTagNode = new TagNode("a");
    aTagNode.addAttribute("href", link, true);
    aTagNode.addAttribute("class", "externallink", true);
    aTagNode.addAttribute("title", link, true);
    aTagNode.addAttribute("rel", "nofollow", true);
    if (withoutSquareBrackets) {
      append(aTagNode);
      aTagNode.addChild(new ContentToken(linkName));
    } else {
      String trimmedText = linkName.trim();
      if (trimmedText.length() > 0) {
        pushNode(aTagNode);
        WikipediaParser.parseRecursive(trimmedText, this, false, true);
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

  public void appendInternalImageLink(String hrefImageLink, String srcImageLink, ImageFormat imageFormat) {
    int pxWidth = imageFormat.getWidth();
    int pxHeight = imageFormat.getHeight();
    String caption = imageFormat.getCaption();
    TagNode divTagNode = new TagNode("div");
    divTagNode.addAttribute("id", "image", false);
    // String link = imageFormat.getLink();
    // if (link != null) {
    // String href = encodeTitleToUrl(link, true);
    // divTagNode.addAttribute("href", href, false);
    // } else {
    if (hrefImageLink.length() != 0) {
      divTagNode.addAttribute("href", hrefImageLink, false);
    }
    // }
    divTagNode.addAttribute("src", srcImageLink, false);
    divTagNode.addObjectAttribute("wikiobject", imageFormat);
    if (pxHeight != -1) {
      if (pxWidth != -1) {
        divTagNode.addAttribute("style", "height:" + pxHeight + "px; " + "width:" + pxWidth + "px", false);
      } else {
        divTagNode.addAttribute("style", "height:" + pxHeight + "px", false);
      }
    } else {
      if (pxWidth != -1) {
        divTagNode.addAttribute("style", "width:" + pxWidth + "px", false);
      }
    }
    pushNode(divTagNode);

    String imageType = imageFormat.getType();
    // TODO: test all these cases
    if (caption != null && caption.length() > 0
        && ("frame".equals(imageType) || "thumb".equals(imageType) || "thumbnail".equals(imageType))) {

      TagNode captionTagNode = new TagNode("div");
      String clazzValue = "caption";
      String type = imageFormat.getType();
      if (type != null) {
        clazzValue = type + clazzValue;
      }
      captionTagNode.addAttribute("class", clazzValue, false);
      //     
      TagStack localStack = WikipediaParser.parseRecursive(caption, this, true, true);
      captionTagNode.addChildren(localStack.getNodeList());
      String altAttribute = imageFormat.getAlt();
      if (altAttribute == null) {
        altAttribute = captionTagNode.getBodyString();
        imageFormat.setAlt(Encoder.encodeHtml(altAttribute));// see issue #25
      }
      pushNode(captionTagNode);
      // WikipediaParser.parseRecursive(caption, this);
      popNode();
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

      // localStack.append(error);
      // return localStack;
      // }

      if (level > Configuration.PARSER_RECURSION_LIMIT) {
        TagNode error = new TagNode("span");
        error.addAttribute("class", "error", true);
        error.addChild(new ContentToken("Error - recursion limit exceeded parsing wiki tags."));
        localStack.append(error);
        return localStack;
      }
      // WikipediaParser parser = new WikipediaParser(rawWikitext,
      // wikiModel.isTemplateTopic(), wikiModel.getWikiListener());
      setModel(wikiModel);
      setNoToC(noTOC);
      runParser();
      return localStack;
    } catch (Exception e) {
      e.printStackTrace();
      TagNode error = new TagNode("span");
      error.addAttribute("class", "error", true);
      error.addChild(new ContentToken(e.getClass().getSimpleName()));
      localStack.append(error);
    } catch (Error e) {
      e.printStackTrace();
      TagNode error = new TagNode("span");
      error.addAttribute("class", "error", true);
      error.addChild(new ContentToken(e.getClass().getSimpleName()));
      localStack.append(error);
    } finally {
      wikiModel.decrementRecursionLevel();
      // wikiModel.decrementParserRecursionLevel();
      if (!createOnlyLocalStack) {
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

   *          this stack.
   * @return <code>true</code> if this collection changed as a result of the
   *         call
   */
  public boolean push(String nodeString) {
    return add(new TagNode(nodeString));
  }
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

    // || ext.equalsIgnoreCase("bmp")) {
    // appendExternalImageLink(link, linkName);
    // return;
    // }
    // }
    TagNode aTagNode = new TagNode("a");
    append(aTagNode);
    aTagNode.addAttribute("href", link, true);
    aTagNode.addAttribute("class", "external free", true);
    aTagNode.addAttribute("title", link, true);
    aTagNode.addAttribute("rel", "nofollow", true);
    aTagNode.addChild(new ContentToken(linkName));
  }
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.