Examples of TagNode


Examples of info.bliki.htmlcleaner.TagNode

    // global wiki model stack
    TagStack globalWikiModelStack = wikiModel.swapStack(localStack);
    try {
      // fix for infinite recursion
      if (wikiModel.incrementParserRecursionCount() > Configuration.GLOBAL_RECURSION_LIMIT) {
        TagNode error = new TagNode("span");
        error.addAttribute("class", "error", true);
        error.addChild(new ContentToken("Error - total recursion count limit exceeded parsing wiki tags."));
        localStack.append(error);
        return localStack;
      }

      int level = wikiModel.incrementRecursionLevel();

      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();
      if (!createOnlyLocalStack) {
        // append the resursively parsed local stack to the global wiki
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(altAttribute);
      }
      pushNode(captionTagNode);
      // WikipediaParser.parseRecursive(caption, this);
      popNode();
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

              String content = contentToken.getContent();
              Utils.escapeXmlToBuffer(content, resultBuffer, true, true, true);
            } else if (item instanceof HTMLTag) {
              ((HTMLTag) item).renderHTML(this, resultBuffer, model);
            } else if (item instanceof TagNode) {
              TagNode node = (TagNode) item;
              Map<String, Object> map = node.getObjectAttributes();
              if (map != null && map.size() > 0) {
                Object attValue = map.get("wikiobject");
                if (attValue instanceof ImageFormat) {
                  imageNodeToText(node, (ImageFormat) attValue, resultBuffer, model);
                }
              } else {
                nodeToHTML(node, resultBuffer, model);
              }
            } else if (item instanceof EndTagToken) {
              EndTagToken node = (EndTagToken) item;
              resultBuffer.append('<');
              resultBuffer.append(node.getName());
              resultBuffer.append("/>");
            }
          }
        }
      } finally {
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

    if (replaceColon()) {
      encodedtopic = encodedtopic.replaceAll(":", "/");
    }
    hrefLink = hrefLink.replace("${title}", encodedtopic);

    TagNode aTagNode = new TagNode("a");
    // append(aTagNode);
    aTagNode.addAttribute("href", hrefLink, true);
    // aTagNode.addChild(new ContentToken(linkText));
    pushNode(aTagNode);
    WikipediaParser.parseRecursive(linkText.trim(), this, false, true);
    popNode();
  }
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

        isbnUrl.append(isbnPureText.charAt(index));
      }
    }

    String isbnString = isbnUrl.toString();
    TagNode aTagNode = new TagNode("a");
    append(aTagNode);
    aTagNode.addAttribute("href", isbnString, true);
    aTagNode.addAttribute("class", "external text", true);
    aTagNode.addAttribute("title", isbnString, true);
    aTagNode.addAttribute("rel", "nofollow", true);
    aTagNode.addChild(new ContentToken(isbnPureText));
  }
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

Examples of info.bliki.htmlcleaner.TagNode

    }
    attributeRenderers.put(attributeClassType, renderer);
  }

  public TagNode appendToCAnchor(String anchor) {
    TagNode aTagNode = new TagNode("a");
    aTagNode.addAttribute("name", anchor, true);
    aTagNode.addAttribute("id", anchor, true);
    return aTagNode;
  }
View Full Code Here

Examples of info.bliki.htmlcleaner.TagNode

    appendEscapedAttributes(buf, tagAtttributes);
  }

  public void renderHTML(ITextConverter converter, Appendable buf, IWikiModel model) throws IOException {
    boolean newLines = false;
    TagNode node = this;
    String name = node.getName();
    List<Object> children = node.getChildren();
    if (children.size() == 0) {
      // don't render empty tags (see Issue98)
      if (!name.equals("a")) {
        // because of section tags allow <a href=\"#Section..." />
        return;
      }
    }

    if (NEW_LINES) {
      if (name.equals("div") || name.equals("p") || name.equals("li") || name.equals("td")) {
        buf.append('\n');
      } else if (name.equals("table") || name.equals("ul") || name.equals("ol") || name.equals("th") || name.equals("tr")
          || name.equals("pre")) {
        buf.append('\n');
        newLines = true;
      }
    }
    buf.append('<');
    buf.append(name);

    Map<String, String> tagAtttributes = node.getAttributes();

    appendAttributes(buf, tagAtttributes);

    if (children.size() == 0) {
      buf.append(" />");
    } else {
      buf.append('>');
      if (newLines) {
        buf.append('\n');
      }
      converter.nodesToText(children, buf, model);
      if (newLines) {
        buf.append('\n');
      }
      buf.append("</");
      buf.append(node.getName());
      buf.append('>');
    }
  }
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.