Package info.bliki.htmlcleaner

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();
    } else {
View Full Code Here


    }
    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

    SectionHeader strPair = new SectionHeader(headLevel, startPosition, endPosition, tocHead, anchor);
    addToTableOfContent(fTableOfContent, strPair, 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

              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

  @Override
  public void appendExternalLink(String uriSchemeName, String link, String linkName, boolean withoutSquareBrackets) {
    if (uriSchemeName.equalsIgnoreCase("tel")) {
      // example for a telephone link
      link = Utils.escapeXml(link, true, false, false);
      TagNode aTagNode = new TagNode("a");
      aTagNode.addAttribute("href", link, true);
      aTagNode.addAttribute("class", "telephonelink", true);
      aTagNode.addAttribute("title", link, 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

  @Override
  public void appendExternalLink(String uriSchemeName, String link, String linkName, boolean withoutSquareBrackets) {
    if (uriSchemeName.equalsIgnoreCase("tel")) {
      // example for a telephone link
      link = Utils.escapeXml(link, true, false, false);
      TagNode aTagNode = new TagNode("a");
      aTagNode.addAttribute("href", link, true);
      aTagNode.addAttribute("class", "telephonelink", true);
      aTagNode.addAttribute("title", link, 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

  }

  public void renderHTML(ITextConverter converter, Appendable buf, IWikiModel model) throws IOException {
    boolean newLinesAfterTag = false;
    boolean newLinesAfterChildren = 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")) {
        buf.append('\n');
        newLinesAfterTag = true;
        newLinesAfterChildren = true;
      } else if (name.equals("pre")) {
        buf.append('\n');
        newLinesAfterTag = false;
        newLinesAfterChildren = true;
      } else if (name.equals("blockquote")) {
        newLinesAfterChildren = 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 (newLinesAfterTag) {
        buf.append('\n');
      }
      converter.nodesToText(children, buf, model);
      if (newLinesAfterChildren) {
        buf.append('\n');
      }
      buf.append("</");
      buf.append(node.getName());
      buf.append('>');
    }
  }
View Full Code Here

      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

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

                    TagToken tag = fWikiModel.getTokenMap().get(tagName);
                    if ((tag != null) && !(tag instanceof HTMLBlockTag)) {
                      tag = (TagToken) tag.clone();

                      if (tag instanceof TagNode) {
                        TagNode node = (TagNode) tag;
                        List<NodeAttribute> attributes = tagNode.getAttributesEx();
                        Attribute attr;
                        for (int i = 1; i < attributes.size(); i++) {
                          attr = attributes.get(i);
                          node.addAttribute(attr.getName(), attr.getValue(), true);
                        }
                      }
                      if (tag instanceof HTMLTag) {
                        // ((HTMLTag) tag).setTemplate(isTemplate());
                      }
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.