Package info.bliki.htmlcleaner

Examples of info.bliki.htmlcleaner.TagNode


  /**
   * {@inheritDoc}
   */
  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


    // || 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

            ContentToken contentToken = (ContentToken) item;
            resultBuffer.append(texEscapeString(contentToken.getContent()));
          } else if (item instanceof HTMLTag) {
            renderLaTeX(((HTMLTag) item), this, resultBuffer, model);
          } else if (item instanceof TagNode) {
            TagNode node = (TagNode) item;
            Map map = node.getObjectAttributes();
            if (map != null && map.size() > 0) {
              Object attValue = map.get("wikiobject");
              if (attValue instanceof ImageFormat) {
                // imageNodeToText(node, (ImageFormat) attValue, resultBuffer,
                // model);
View Full Code Here

  public ITableOfContent appendHead(String rawHead, int headLevel, boolean noToC, int headCounter, int startPosition,
      int endPosition) {
    TagStack localStack = WikipediaParser.parseRecursive(rawHead.trim(), this, true, true);

    WPTag headTagNode = new WPTag("h" + headLevel);
    TagNode spanTagNode = new TagNode("span");
    // Example:
    // <h2><span class="mw-headline" id="Header_level_2">Header level
    // 2</span></h2>
    spanTagNode.addChildren(localStack.getNodeList());
    headTagNode.addChild(spanTagNode);
    String tocHead = headTagNode.getBodyString();
    String anchor = Encoder.encodeDotUrl(tocHead);
    createTableOfContent(false);
    if (!noToC && (headCounter > 3)) {
      fTableOfContentTag.setShowToC(true);
    }
    if (fToCSet.contains(anchor)) {
      String newAnchor = anchor;
      for (int i = 2; i < Integer.MAX_VALUE; i++) {
        newAnchor = anchor + '_' + Integer.toString(i);
        if (!fToCSet.contains(newAnchor)) {
          break;
        }
      }
      anchor = newAnchor;
    }
    fToCSet.add(anchor);
    SectionHeader strPair = new SectionHeader(headLevel, startPosition, endPosition, tocHead, anchor);
    addToTableOfContent(fTableOfContent, strPair, headLevel);
    if (getRecursionLevel() == 1) {
      buildEditLinkUrl(fSectionCounter++);
    }
    spanTagNode.addAttribute("class", "mw-headline", true);
    spanTagNode.addAttribute("id", anchor, true);

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

  public void appendInternalImageLink(String hrefImageLink, String srcImageLink, ImageFormat imageFormat) {
    int pxWidth = imageFormat.getWidth();
    int pxHeight = imageFormat.getHeight();
    String caption = imageFormat.getCaption();
    String imageType = imageFormat.getType();
    TagNode divInnerTagNode = new TagNode("div");
    divInnerTagNode.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) {
      divInnerTagNode.addAttribute("href", hrefImageLink, false);
    }
    // }

    divInnerTagNode.addAttribute("src", srcImageLink, false);
    setDefaultThumbWidth(imageFormat);
    divInnerTagNode.addObjectAttribute("wikiobject", imageFormat);
    // if (pxHeight != -1) {
    // if (pxWidth != -1) {
    // divInnerTagNode.addAttribute("style", "height:" + pxHeight + "px; " +
    // "width:" + pxWidth + "px", false);
    // } else {
    // divInnerTagNode.addAttribute("style", "height:" + pxHeight + "px",
    // false);
    // }
    // } else {
    // if (pxWidth != -1) {
    // divInnerTagNode.addAttribute("style", "width:" + pxWidth + "px", false);
    // }
    // }
    pushNode(divInnerTagNode);

    // 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

  }

  @Override
  public void renderHTML(ITextConverter converter, Appendable buf, IWikiModel model) throws IOException {

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

    StringBuilder chartUrl = new StringBuilder(100);
    Utils.appendEscapedAttribute(chartUrl, "url", tagAtttributes);
    // chart type
    Utils.appendAmpersandEscapedAttribute(chartUrl, "cht", tagAtttributes);
View Full Code Here

  @Override
  public void renderHTML(ITextConverter converter, Appendable buf, IWikiModel model) throws IOException {

    buf.append('\n');
    buf.append("<applet");
    TagNode node = this;
    Map<String, String> tagAtttributes = node.getAttributes();

    appendAttributes(buf, tagAtttributes);
    buf.append(">\n");
    // List children = node.getChildren();
    // if (children.size() == 0) {
View Full Code Here

    if (replaceColon()) {
      encodedtopic = encodedtopic.replace(':', '/');
    }
    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

        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

    // || 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

Related Classes of info.bliki.htmlcleaner.TagNode

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.