Package info.bliki.htmlcleaner

Examples of info.bliki.htmlcleaner.ContentToken


    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


          }
        } else if (rawNamespaceTopic.charAt(colonIndex + 1) == '=') {
          // found an SMW attribute
          String attributeValue = rawNamespaceTopic.substring(colonIndex + 2);
          if (addSemanticAttribute(nameSpace, attributeValue)) {
            append(new ContentToken(attributeValue));
            return true;
          }
        }

      }
View Full Code Here

    pushNode(aTagNode);
    if (parseRecursive) {
      WikipediaParser.parseRecursive(topicDescription.trim(), this, false, true);
    } else {
      aTagNode.addChild(new ContentToken(topicDescription));
    }
    popNode();
  }
View Full Code Here

    if (whiteStart) {
      try {
        final int whiteEndPosition = fCurrentPosition - diff;
        int count = whiteEndPosition - whiteStartPosition;
        if (count > 0) {
          fWikiModel.append(new ContentToken(fStringSource.substring(whiteStartPosition, whiteStartPosition + count)));
        }
      } finally {
        fWhiteStart = false;
      }
    }
View Full Code Here

        fWikiModel.append(tag);
      } else {
        fWikiModel.pushNode(tag);
        if (null != bodyString) {
          if (tag instanceof INoBodyParsingTag) {
            ((TagNode) tag).addChild(new ContentToken(bodyString));
          } else {
            // recursively filter tags within the tags body string
            WikipediaParser.parseRecursive(bodyString.trim(), fWikiModel, false, true);
          }
        }
        if (tag instanceof IBodyTag) {
          fWikiModel.popNode();
        }
      }
    } catch (IllegalArgumentException e) {
      TagNode divTagNode = new TagNode("div");
      divTagNode.addAttribute("class", "error", true);
      divTagNode.addChild(new ContentToken("IllegalArgumentException: " + command + " - " + e.getMessage()));
      fWikiModel.append(divTagNode);
      e.printStackTrace();
    } catch (Throwable e) {
      e.printStackTrace();
      TagNode divTagNode = new TagNode("div");
      divTagNode.addAttribute("class", "error", true);
      divTagNode.addChild(new ContentToken(command + ": " + e.getMessage()));
      fWikiModel.append(divTagNode);
      e.printStackTrace();
      return;
    }
  }
View Full Code Here

  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

  private void parseNextPHPBBCode(String rawWikitext) {
    int index = rawWikitext.indexOf('[');
    int lastIndex = 0;
    int tempIndex = -1;
    if (index < 0) {
      fWikiModel.append(new ContentToken(rawWikitext));
      return;
    }
    try {
      while (index >= 0) {
        String temp = rawWikitext.substring(lastIndex, index);
        if (temp.length() > 0) {
          fWikiModel.append(new ContentToken(temp));
        }
        tempIndex = parsePHPBBCodeRecursive(rawWikitext, index + 1);
        if (tempIndex < 0) {
          lastIndex = index + 1;
          index = rawWikitext.indexOf('[', index + 1);
        } else {
          lastIndex = tempIndex;
          index = rawWikitext.indexOf('[', tempIndex);
        }
      }
    } catch (IndexOutOfBoundsException e) {
      //
    }
    if (lastIndex < rawWikitext.length()) {
      fWikiModel.append(new ContentToken(rawWikitext.substring(lastIndex)));
    }
  }
View Full Code Here

    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

    pushNode(aTagNode);
    if (parseRecursive) {
      WikipediaParser.parseRecursive(topicDescription.trim(), this, false, true);
    } else {
      aTagNode.addChild(new ContentToken(topicDescription));
    }
    popNode();
  }
View Full Code Here

    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

TOP

Related Classes of info.bliki.htmlcleaner.ContentToken

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.